summaryrefslogtreecommitdiff
path: root/tests/test_python.py
diff options
context:
space:
mode:
authorNed Batchelder <ned@nedbatchelder.com>2021-04-14 11:50:15 -0400
committerNed Batchelder <ned@nedbatchelder.com>2021-04-14 12:52:39 -0400
commit50cc68846f9b78a4d0984c5a9475203b3c87c1e0 (patch)
treecad38e5b57c4eebab80ad99c645396200a3b824c /tests/test_python.py
parent52e5088a39b4d47e124a79c357dd04233658c583 (diff)
downloadpython-coveragepy-git-50cc68846f9b78a4d0984c5a9475203b3c87c1e0.tar.gz
test: improve zipfile test
Before this commit, the GetZipBytesTest.test_get_encoded_zip_files test was flaky on Python 3.10.0a7. Since I had just added new files to the common zip file, I tried splitting the newly added stuff into its own file, and that seemed to fix the problem.
Diffstat (limited to 'tests/test_python.py')
-rw-r--r--tests/test_python.py22
1 files changed, 13 insertions, 9 deletions
diff --git a/tests/test_python.py b/tests/test_python.py
index 0175f5af..dc9609c9 100644
--- a/tests/test_python.py
+++ b/tests/test_python.py
@@ -19,18 +19,22 @@ class GetZipBytesTest(CoverageTest):
run_in_temp_dir = False
- def test_get_encoded_zip_files(self):
+ @pytest.mark.parametrize(
+ "encoding",
+ ["utf8", "gb2312", "hebrew", "shift_jis", "cp1252"],
+ )
+ def test_get_encoded_zip_files(self, encoding):
# See igor.py, do_zipmods, for the text of these files.
zip_file = "tests/zipmods.zip"
sys.path.append(zip_file) # So we can import the files.
- for encoding in ["utf8", "gb2312", "hebrew", "shift_jis", "cp1252"]:
- filename = zip_file + "/encoded_" + encoding + ".py"
- filename = filename.replace("/", os.sep)
- zip_data = get_zip_bytes(filename)
- zip_text = zip_data.decode(encoding)
- assert 'All OK' in zip_text
- # Run the code to see that we really got it encoded properly.
- __import__("encoded_"+encoding)
+ filename = zip_file + "/encoded_" + encoding + ".py"
+ filename = filename.replace("/", os.sep)
+ zip_data = get_zip_bytes(filename)
+ zip_text = zip_data.decode(encoding)
+ assert 'All OK' in zip_text
+ # Run the code to see that we really got it encoded properly.
+ mod = __import__("encoded_"+encoding)
+ assert mod.encoding == encoding
def test_source_for_file(tmpdir):