diff options
| author | Nick Coghlan <ncoghlan@gmail.com> | 2008-12-15 11:41:05 (GMT) |
|---|---|---|
| committer | Nick Coghlan <ncoghlan@gmail.com> | 2008-12-15 11:41:05 (GMT) |
| commit | 68060013eaa13ddd26bf4eb804d3dce7b29813a9 (patch) | |
| tree | 7d8ccb45af30f4201fffb3b5f2d15dcf37bebff5 /Lib/test | |
| parent | 60b2e38b68e484830e3e3857197b0d9201c3ac22 (diff) | |
| download | cpython-68060013eaa13ddd26bf4eb804d3dce7b29813a9.zip cpython-68060013eaa13ddd26bf4eb804d3dce7b29813a9.tar.gz cpython-68060013eaa13ddd26bf4eb804d3dce7b29813a9.tar.bz2 | |
Issue #4197: Fix the remaining part of the doctest-in-zipfile problem by giving linecache access to the module globals when available
Diffstat (limited to 'Lib/test')
| -rw-r--r-- | Lib/test/test_zipimport_support.py | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/Lib/test/test_zipimport_support.py b/Lib/test/test_zipimport_support.py index 3daf90f..b416b81 100644 --- a/Lib/test/test_zipimport_support.py +++ b/Lib/test/test_zipimport_support.py @@ -173,6 +173,35 @@ class ZipSupportTests(ImportHooksBaseTestCase): for obj in known_good_tests: _run_object_doctest(obj, test_zipped_doctest) + def test_doctest_main_issue4197(self): + test_src = textwrap.dedent("""\ + class Test: + ">>> 'line 2'" + pass + + import doctest + doctest.testmod() + """) + pattern = 'File "%s", line 2, in %s' + with temp_dir() as d: + script_name = _make_test_script(d, 'script', test_src) + exit_code, data = _run_python(script_name) + expected = pattern % (script_name, "__main__.Test") + if verbose: + print "Expected line", expected + print "Got stdout:" + print data + self.assert_(expected in data) + zip_name, run_name = _make_test_zip(d, "test_zip", + script_name, '__main__.py') + exit_code, data = _run_python(zip_name) + expected = pattern % (run_name, "__main__.Test") + if verbose: + print "Expected line", expected + print "Got stdout:" + print data + self.assert_(expected in data) + def test_pdb_issue4201(self): test_src = textwrap.dedent("""\ def f(): |
