summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_zipimport_support.py
diff options
context:
space:
mode:
authorR David Murray <rdmurray@bitdance.com>2012-09-10 14:16:46 (GMT)
committerR David Murray <rdmurray@bitdance.com>2012-09-10 14:16:46 (GMT)
commitc3bfb01a959235135c727d532e3e89bbf2658a09 (patch)
tree2f6dd0d97ea06d535f7b4349c28df02b7635396d /Lib/test/test_zipimport_support.py
parentb83b287f17aa8f59e378f9d6ff77401c42d36dd3 (diff)
parent5abd76a75d633a1ba6f5fcc66b0bc4799b9e2eaa (diff)
downloadcpython-c3bfb01a959235135c727d532e3e89bbf2658a09.zip
cpython-c3bfb01a959235135c727d532e3e89bbf2658a09.tar.gz
cpython-c3bfb01a959235135c727d532e3e89bbf2658a09.tar.bz2
Merge #14649: clarify DocTestSuite error when there are no docstrings.
Also adds tests to verify the documented behavior (which is probably a bug, as indicated in the added comments). Patch by Chris Jerdonek.
Diffstat (limited to 'Lib/test/test_zipimport_support.py')
-rw-r--r--Lib/test/test_zipimport_support.py21
1 files changed, 16 insertions, 5 deletions
diff --git a/Lib/test/test_zipimport_support.py b/Lib/test/test_zipimport_support.py
index 0c93a8c..f7f3398 100644
--- a/Lib/test/test_zipimport_support.py
+++ b/Lib/test/test_zipimport_support.py
@@ -29,7 +29,8 @@ verbose = test.support.verbose
# test_cmd_line_script (covers the zipimport support in runpy)
# Retrieve some helpers from other test cases
-from test import test_doctest, sample_doctest
+from test import (test_doctest, sample_doctest, sample_doctest_no_doctests,
+ sample_doctest_no_docstrings)
def _run_object_doctest(obj, module):
@@ -105,16 +106,26 @@ class ZipSupportTests(unittest.TestCase):
"test_zipped_doctest")
test_src = test_src.replace("test.sample_doctest",
"sample_zipped_doctest")
- sample_src = inspect.getsource(sample_doctest)
- sample_src = sample_src.replace("test.test_doctest",
- "test_zipped_doctest")
+ # The sample doctest files rewritten to include in the zipped version.
+ sample_sources = {}
+ for mod in [sample_doctest, sample_doctest_no_doctests,
+ sample_doctest_no_docstrings]:
+ src = inspect.getsource(mod)
+ src = src.replace("test.test_doctest", "test_zipped_doctest")
+ # Rewrite the module name so that, for example,
+ # "test.sample_doctest" becomes "sample_zipped_doctest".
+ mod_name = mod.__name__.split(".")[-1]
+ mod_name = mod_name.replace("sample_", "sample_zipped_")
+ sample_sources[mod_name] = src
+
with temp_dir() as d:
script_name = make_script(d, 'test_zipped_doctest',
test_src)
zip_name, run_name = make_zip_script(d, 'test_zip',
script_name)
z = zipfile.ZipFile(zip_name, 'a')
- z.writestr("sample_zipped_doctest.py", sample_src)
+ for mod_name, src in sample_sources.items():
+ z.writestr(mod_name + ".py", src)
z.close()
if verbose:
zip_file = zipfile.ZipFile(zip_name, 'r')