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