| 569 | """ |
| 570 | |
| 571 | def run(self, test, compileflags=None, out=None, clear_globs=True): |
| 572 | |
| 573 | # Hack: ipython needs access to the execution context of the example, |
| 574 | # so that it can propagate user variables loaded by %run into |
| 575 | # test.globs. We put them here into our modified %run as a function |
| 576 | # attribute. Our new %run will then only make the namespace update |
| 577 | # when called (rather than unconditionally updating test.globs here |
| 578 | # for all examples, most of which won't be calling %run anyway). |
| 579 | #_ip._ipdoctest_test_globs = test.globs |
| 580 | #_ip._ipdoctest_test_filename = test.filename |
| 581 | |
| 582 | test.globs.update(_ip.user_ns) |
| 583 | |
| 584 | # Override terminal size to standardise traceback format |
| 585 | with modified_env({'COLUMNS': '80', 'LINES': '24'}): |
| 586 | return super(IPDocTestRunner,self).run(test, |
| 587 | compileflags,out,clear_globs) |
| 588 | |
| 589 | |
| 590 | class DocFileCase(doctest.DocFileCase): |