Modified test setup that syncs with ipython namespace
(self)
| 268 | raise self.failureException(self.format_failure(new.getvalue())) |
| 269 | |
| 270 | def setUp(self): |
| 271 | """Modified test setup that syncs with ipython namespace""" |
| 272 | #print "setUp test", self._dt_test.examples # dbg |
| 273 | if isinstance(self._dt_test.examples[0], IPExample): |
| 274 | # for IPython examples *only*, we swap the globals with the ipython |
| 275 | # namespace, after updating it with the globals (which doctest |
| 276 | # fills with the necessary info from the module being tested). |
| 277 | self.user_ns_orig = {} |
| 278 | self.user_ns_orig.update(_ip.user_ns) |
| 279 | _ip.user_ns.update(self._dt_test.globs) |
| 280 | # We must remove the _ key in the namespace, so that Python's |
| 281 | # doctest code sets it naturally |
| 282 | _ip.user_ns.pop('_', None) |
| 283 | _ip.user_ns['__builtins__'] = builtin_mod |
| 284 | self._dt_test.globs = _ip.user_ns |
| 285 | |
| 286 | super(DocTestCase, self).setUp() |
| 287 | |
| 288 | def tearDown(self): |
| 289 |