diff --git a/IPython/extensions/tests/test_autoreload.py b/IPython/extensions/tests/test_autoreload.py index 89c288b..ebeb9b3 100644 --- a/IPython/extensions/tests/test_autoreload.py +++ b/IPython/extensions/tests/test_autoreload.py @@ -151,6 +151,59 @@ class TestAutoreload(Fixture): with tt.AssertNotPrints(('[autoreload of %s failed:' % mod_name), channel='stderr'): self.shell.run_code("pass") # trigger another reload + def test_reload_class_attributes(self): + self.shell.magic_autoreload("2") + mod_name, mod_fn = self.new_module(textwrap.dedent(""" + class MyClass: + + def __init__(self, a=10): + self.a = a + self.b = 22 + # self.toto = 33 + + def square(self): + print('compute square') + return self.a*self.a + """)) + self.shell.run_code("from %s import MyClass" % mod_name) + self.shell.run_code("c = MyClass(5)") + self.shell.run_code("c.square()") + with nt.assert_raises(AttributeError): + self.shell.run_code("c.cube()") + with nt.assert_raises(AttributeError): + self.shell.run_code("c.power(5)") + self.shell.run_code("c.b") + with nt.assert_raises(AttributeError): + self.shell.run_code("c.toto") + + + self.write_file(mod_fn, textwrap.dedent(""" + class MyClass: + + def __init__(self, a=10): + self.a = a + self.b = 11 + + def power(self, p): + print('compute power '+str(p)) + return self.a**p + """)) + + self.shell.run_code("d = MyClass(5)") + self.shell.run_code("d.power(5)") + with nt.assert_raises(AttributeError): + self.shell.run_code("c.cube()") + with nt.assert_raises(AttributeError): + self.shell.run_code("c.square(5)") + self.shell.run_code("c.b") + self.shell.run_code("c.a") + with nt.assert_raises(AttributeError): + self.shell.run_code("c.toto") + + + + + def _check_smoketest(self, use_aimport=True): """ @@ -340,3 +393,7 @@ x = -99 def test_smoketest_autoreload(self): self._check_smoketest(use_aimport=False) + + + + diff --git a/IPython/testing/iptest.py b/IPython/testing/iptest.py index 633cb72..445e826 100644 --- a/IPython/testing/iptest.py +++ b/IPython/testing/iptest.py @@ -386,6 +386,12 @@ def run_iptest(): monkeypatch_xunit() arg1 = sys.argv[1] + if arg1.startswith('IPython/'): + if arg1.endswith('.py'): + arg1 = arg1[:-3] + sys.argv[1] = arg1.replace('/', '.') + + arg1 = sys.argv[1] if arg1 in test_sections: section = test_sections[arg1] sys.argv[1:2] = section.includes