##// END OF EJS Templates
add tests
Matthias Bussonnier -
Show More
@@ -151,6 +151,59 b' class TestAutoreload(Fixture):'
151 with tt.AssertNotPrints(('[autoreload of %s failed:' % mod_name), channel='stderr'):
151 with tt.AssertNotPrints(('[autoreload of %s failed:' % mod_name), channel='stderr'):
152 self.shell.run_code("pass") # trigger another reload
152 self.shell.run_code("pass") # trigger another reload
153
153
154 def test_reload_class_attributes(self):
155 self.shell.magic_autoreload("2")
156 mod_name, mod_fn = self.new_module(textwrap.dedent("""
157 class MyClass:
158
159 def __init__(self, a=10):
160 self.a = a
161 self.b = 22
162 # self.toto = 33
163
164 def square(self):
165 print('compute square')
166 return self.a*self.a
167 """))
168 self.shell.run_code("from %s import MyClass" % mod_name)
169 self.shell.run_code("c = MyClass(5)")
170 self.shell.run_code("c.square()")
171 with nt.assert_raises(AttributeError):
172 self.shell.run_code("c.cube()")
173 with nt.assert_raises(AttributeError):
174 self.shell.run_code("c.power(5)")
175 self.shell.run_code("c.b")
176 with nt.assert_raises(AttributeError):
177 self.shell.run_code("c.toto")
178
179
180 self.write_file(mod_fn, textwrap.dedent("""
181 class MyClass:
182
183 def __init__(self, a=10):
184 self.a = a
185 self.b = 11
186
187 def power(self, p):
188 print('compute power '+str(p))
189 return self.a**p
190 """))
191
192 self.shell.run_code("d = MyClass(5)")
193 self.shell.run_code("d.power(5)")
194 with nt.assert_raises(AttributeError):
195 self.shell.run_code("c.cube()")
196 with nt.assert_raises(AttributeError):
197 self.shell.run_code("c.square(5)")
198 self.shell.run_code("c.b")
199 self.shell.run_code("c.a")
200 with nt.assert_raises(AttributeError):
201 self.shell.run_code("c.toto")
202
203
204
205
206
154
207
155 def _check_smoketest(self, use_aimport=True):
208 def _check_smoketest(self, use_aimport=True):
156 """
209 """
@@ -340,3 +393,7 b' x = -99'
340
393
341 def test_smoketest_autoreload(self):
394 def test_smoketest_autoreload(self):
342 self._check_smoketest(use_aimport=False)
395 self._check_smoketest(use_aimport=False)
396
397
398
399
@@ -386,6 +386,12 b' def run_iptest():'
386 monkeypatch_xunit()
386 monkeypatch_xunit()
387
387
388 arg1 = sys.argv[1]
388 arg1 = sys.argv[1]
389 if arg1.startswith('IPython/'):
390 if arg1.endswith('.py'):
391 arg1 = arg1[:-3]
392 sys.argv[1] = arg1.replace('/', '.')
393
394 arg1 = sys.argv[1]
389 if arg1 in test_sections:
395 if arg1 in test_sections:
390 section = test_sections[arg1]
396 section = test_sections[arg1]
391 sys.argv[1:2] = section.includes
397 sys.argv[1:2] = section.includes
General Comments 0
You need to be logged in to leave comments. Login now