summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_cmd_line_script.py
diff options
context:
space:
mode:
authorElvis Pranskevichus <elvis@magic.io>2018-11-07 18:34:59 (GMT)
committerSerhiy Storchaka <storchaka@gmail.com>2018-11-07 18:34:59 (GMT)
commita6e956bcb0edbfe7f18af9be2215a5326ea6bf05 (patch)
tree8b3dc9558493973f8e069a76170e4ff8dc6665d4 /Lib/test/test_cmd_line_script.py
parentbfe1839aa994f0d84471254418a4ecfa7c7c9b9c (diff)
downloadcpython-a6e956bcb0edbfe7f18af9be2215a5326ea6bf05.zip
cpython-a6e956bcb0edbfe7f18af9be2215a5326ea6bf05.tar.gz
cpython-a6e956bcb0edbfe7f18af9be2215a5326ea6bf05.tar.bz2
bpo-34726: Fix handling of hash-based pycs in zipimport. (GH-10327)
Current support for hash-based bytecode files in `zipimport` is rather sparse, which leads to test failures when the test suite is ran with the ``SOURCE_DATE_EPOCH`` environment variable set. This teaches zipimport to handle hash-based pycs properly.
Diffstat (limited to 'Lib/test/test_cmd_line_script.py')
-rw-r--r--Lib/test/test_cmd_line_script.py26
1 files changed, 24 insertions, 2 deletions
diff --git a/Lib/test/test_cmd_line_script.py b/Lib/test/test_cmd_line_script.py
index bc812ea..85d2a4b 100644
--- a/Lib/test/test_cmd_line_script.py
+++ b/Lib/test/test_cmd_line_script.py
@@ -259,10 +259,32 @@ class CmdLineTest(unittest.TestCase):
self._check_script(zip_name, run_name, zip_name, zip_name, '',
zipimport.zipimporter)
- def test_zipfile_compiled(self):
+ def test_zipfile_compiled_timestamp(self):
with support.temp_dir() as script_dir:
script_name = _make_test_script(script_dir, '__main__')
- compiled_name = py_compile.compile(script_name, doraise=True)
+ compiled_name = py_compile.compile(
+ script_name, doraise=True,
+ invalidation_mode=py_compile.PycInvalidationMode.TIMESTAMP)
+ zip_name, run_name = make_zip_script(script_dir, 'test_zip', compiled_name)
+ self._check_script(zip_name, run_name, zip_name, zip_name, '',
+ zipimport.zipimporter)
+
+ def test_zipfile_compiled_checked_hash(self):
+ with support.temp_dir() as script_dir:
+ script_name = _make_test_script(script_dir, '__main__')
+ compiled_name = py_compile.compile(
+ script_name, doraise=True,
+ invalidation_mode=py_compile.PycInvalidationMode.CHECKED_HASH)
+ zip_name, run_name = make_zip_script(script_dir, 'test_zip', compiled_name)
+ self._check_script(zip_name, run_name, zip_name, zip_name, '',
+ zipimport.zipimporter)
+
+ def test_zipfile_compiled_unchecked_hash(self):
+ with support.temp_dir() as script_dir:
+ script_name = _make_test_script(script_dir, '__main__')
+ compiled_name = py_compile.compile(
+ script_name, doraise=True,
+ invalidation_mode=py_compile.PycInvalidationMode.UNCHECKED_HASH)
zip_name, run_name = make_zip_script(script_dir, 'test_zip', compiled_name)
self._check_script(zip_name, run_name, zip_name, zip_name, '',
zipimport.zipimporter)