##// END OF EJS Templates
implement test for numpy objects autoreload
sleeping -
Show More
@@ -274,6 +274,39 b' class TestAutoreload(Fixture):'
274 with self.assertRaises(AttributeError):
274 with self.assertRaises(AttributeError):
275 self.shell.run_code(f"{object_name}.toto")
275 self.shell.run_code(f"{object_name}.toto")
276
276
277 def test_comparing_numpy_structures(self):
278 self.shell.magic_autoreload("2")
279 mod_name, mod_fn = self.new_module(
280 textwrap.dedent(
281 """
282 import numpy as np
283 class MyClass:
284 a = (np.array((.1, .2)),
285 np.array((.2, .3)))
286 """
287 )
288 )
289 self.shell.run_code("from %s import MyClass" % mod_name)
290 self.shell.run_code("first = MyClass()")
291
292 # change property `a`
293 self.write_file(
294 mod_fn,
295 textwrap.dedent(
296 """
297 import numpy as np
298 class MyClass:
299 a = (np.array((.3, .4)),
300 np.array((.5, .6)))
301 """
302 ),
303 )
304
305 with tt.AssertNotPrints(
306 ("[autoreload of %s failed:" % mod_name), channel="stderr"
307 ):
308 self.shell.run_code("pass") # trigger another reload
309
277 def test_autoload_newly_added_objects(self):
310 def test_autoload_newly_added_objects(self):
278 self.shell.magic_autoreload("3")
311 self.shell.magic_autoreload("3")
279 mod_code = """
312 mod_code = """
General Comments 0
You need to be logged in to leave comments. Login now