##// END OF EJS Templates
Merge pull request #13400 from sleeping-h/fix-autoreload-issue-12870...
Matthias Bussonnier -
r27342:355c5f37 merge
parent child Browse files
Show More
@@ -321,6 +321,10 b' def update_class(old, new):'
321 321 except (AttributeError, TypeError):
322 322 pass
323 323 continue
324 except ValueError:
325 # can't compare nested structures containing
326 # numpy arrays using `==`
327 pass
324 328
325 329 if update_generic(old_obj, new_obj):
326 330 continue
@@ -29,6 +29,7 b' from unittest import TestCase'
29 29
30 30 from IPython.extensions.autoreload import AutoreloadMagics
31 31 from IPython.core.events import EventManager, pre_run_cell
32 from IPython.testing.decorators import skipif_not_numpy
32 33
33 34 if platform.python_implementation() == "PyPy":
34 35 pytest.skip(
@@ -274,6 +275,40 b' class TestAutoreload(Fixture):'
274 275 with self.assertRaises(AttributeError):
275 276 self.shell.run_code(f"{object_name}.toto")
276 277
278 @skipif_not_numpy
279 def test_comparing_numpy_structures(self):
280 self.shell.magic_autoreload("2")
281 mod_name, mod_fn = self.new_module(
282 textwrap.dedent(
283 """
284 import numpy as np
285 class MyClass:
286 a = (np.array((.1, .2)),
287 np.array((.2, .3)))
288 """
289 )
290 )
291 self.shell.run_code("from %s import MyClass" % mod_name)
292 self.shell.run_code("first = MyClass()")
293
294 # change property `a`
295 self.write_file(
296 mod_fn,
297 textwrap.dedent(
298 """
299 import numpy as np
300 class MyClass:
301 a = (np.array((.3, .4)),
302 np.array((.5, .6)))
303 """
304 ),
305 )
306
307 with tt.AssertNotPrints(
308 ("[autoreload of %s failed:" % mod_name), channel="stderr"
309 ):
310 self.shell.run_code("pass") # trigger another reload
311
277 312 def test_autoload_newly_added_objects(self):
278 313 self.shell.magic_autoreload("3")
279 314 mod_code = """
General Comments 0
You need to be logged in to leave comments. Login now