summaryrefslogtreecommitdiff
path: root/tests/test_python.py
diff options
context:
space:
mode:
authorNed Batchelder <ned@nedbatchelder.com>2015-01-01 13:40:45 -0500
committerNed Batchelder <ned@nedbatchelder.com>2015-01-01 13:40:45 -0500
commit7170c660826939a0f31137300bc29c5843095e47 (patch)
treeab261037723283b644d2649ce6b38658239932d7 /tests/test_python.py
parented86e7085ae690f57335d823beb8c9b1327787f5 (diff)
downloadpython-coveragepy-7170c660826939a0f31137300bc29c5843095e47.tar.gz
Move python source understanding into python.py
Diffstat (limited to 'tests/test_python.py')
-rw-r--r--tests/test_python.py27
1 files changed, 27 insertions, 0 deletions
diff --git a/tests/test_python.py b/tests/test_python.py
new file mode 100644
index 0000000..f2c18a1
--- /dev/null
+++ b/tests/test_python.py
@@ -0,0 +1,27 @@
+"""Tests of coverage/python.py"""
+
+import os
+import sys
+
+from coverage.python import get_zip_bytes
+
+from tests.coveragetest import CoverageTest
+
+
+class GetZipBytesTest(CoverageTest):
+ """Tests of `get_zip_bytes`."""
+
+ run_in_temp_dir = False
+
+ def test_get_encoded_zip_files(self):
+ # 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"]:
+ filename = zip_file + "/encoded_" + encoding + ".py"
+ filename = filename.replace("/", os.sep)
+ zip_data = get_zip_bytes(filename)
+ zip_text = zip_data.decode(encoding)
+ self.assertIn('All OK', zip_text)
+ # Run the code to see that we really got it encoded properly.
+ __import__("encoded_"+encoding)