Show More
@@ -164,20 +164,26 b' class TestAutoreload(Fixture):' | |||||
164 | def square(self): |
|
164 | def square(self): | |
165 | print('compute square') |
|
165 | print('compute square') | |
166 | return self.a*self.a |
|
166 | return self.a*self.a | |
167 |
""" |
|
167 | """ | |
|
168 | ) | |||
|
169 | ) | |||
168 | self.shell.run_code("from %s import MyClass" % mod_name) |
|
170 | self.shell.run_code("from %s import MyClass" % mod_name) | |
169 |
self.shell.run_code(" |
|
171 | self.shell.run_code("first = MyClass(5)") | |
170 |
self.shell.run_code(" |
|
172 | self.shell.run_code("first.square()") | |
171 | with nt.assert_raises(AttributeError): |
|
173 | with nt.assert_raises(AttributeError): | |
172 |
self.shell.run_code(" |
|
174 | self.shell.run_code("first.cube()") | |
173 | with nt.assert_raises(AttributeError): |
|
175 | with nt.assert_raises(AttributeError): | |
174 |
self.shell.run_code(" |
|
176 | self.shell.run_code("first.power(5)") | |
175 |
self.shell.run_code(" |
|
177 | self.shell.run_code("first.b") | |
176 | with nt.assert_raises(AttributeError): |
|
178 | with nt.assert_raises(AttributeError): | |
177 |
self.shell.run_code(" |
|
179 | self.shell.run_code("first.toto") | |
178 |
|
180 | |||
|
181 | # remove square, add power | |||
179 |
|
182 | |||
180 |
self.write_file( |
|
183 | self.write_file( | |
|
184 | mod_fn, | |||
|
185 | textwrap.dedent( | |||
|
186 | """ | |||
181 |
|
|
187 | class MyClass: | |
182 |
|
|
188 | ||
183 |
|
|
189 | def __init__(self, a=10): | |
@@ -187,23 +193,22 b' class TestAutoreload(Fixture):' | |||||
187 |
|
|
193 | def power(self, p): | |
188 | print('compute power '+str(p)) |
|
194 | print('compute power '+str(p)) | |
189 |
|
|
195 | return self.a**p | |
190 |
|
|
196 | """ | |
191 |
|
197 | ), | ||
192 | self.shell.run_code("d = MyClass(5)") |
|
198 | ) | |
193 | self.shell.run_code("d.power(5)") |
|
199 | ||
194 | with nt.assert_raises(AttributeError): |
|
200 | self.shell.run_code("second = MyClass(5)") | |
195 | self.shell.run_code("c.cube()") |
|
201 | ||
196 | with nt.assert_raises(AttributeError): |
|
202 | for object_name in {'first', 'second'}: | |
197 |
self.shell.run_code(" |
|
203 | self.shell.run_code("{object_name}.power(5)".format(object_name=object_name)) | |
198 | self.shell.run_code("c.b") |
|
204 | with nt.assert_raises(AttributeError): | |
199 | self.shell.run_code("c.a") |
|
205 | self.shell.run_code("{object_name}.cube()".format(object_name=object_name)) | |
200 | with nt.assert_raises(AttributeError): |
|
206 | with nt.assert_raises(AttributeError): | |
201 | self.shell.run_code("c.toto") |
|
207 | self.shell.run_code("{object_name}.square(5)".format(object_name=object_name)) | |
202 |
|
208 | self.shell.run_code("{object_name}.b".format(object_name=object_name)) | ||
203 |
|
209 | self.shell.run_code("{object_name}.a".format(object_name=object_name)) | ||
204 |
|
210 | with nt.assert_raises(AttributeError): | ||
205 |
|
211 | self.shell.run_code("{object_name}.toto".format(object_name=object_name)) | ||
206 |
|
||||
207 |
|
212 | |||
208 | def _check_smoketest(self, use_aimport=True): |
|
213 | def _check_smoketest(self, use_aimport=True): | |
209 | """ |
|
214 | """ |
General Comments 0
You need to be logged in to leave comments.
Login now