OLD | NEW |
(Empty) | |
| 1 # Licensed under the Apache License: http://www.apache.org/licenses/LICENSE-2.0 |
| 2 # For details: https://bitbucket.org/ned/coveragepy/src/default/NOTICE.txt |
| 3 |
| 4 """Tests of coverage/python.py""" |
| 5 |
| 6 import os |
| 7 import sys |
| 8 |
| 9 from coverage.python import get_zip_bytes |
| 10 |
| 11 from tests.coveragetest import CoverageTest |
| 12 |
| 13 |
| 14 class GetZipBytesTest(CoverageTest): |
| 15 """Tests of `get_zip_bytes`.""" |
| 16 |
| 17 run_in_temp_dir = False |
| 18 |
| 19 def test_get_encoded_zip_files(self): |
| 20 # See igor.py, do_zipmods, for the text of these files. |
| 21 zip_file = "tests/zipmods.zip" |
| 22 sys.path.append(zip_file) # So we can import the files. |
| 23 for encoding in ["utf8", "gb2312", "hebrew", "shift_jis"]: |
| 24 filename = zip_file + "/encoded_" + encoding + ".py" |
| 25 filename = filename.replace("/", os.sep) |
| 26 zip_data = get_zip_bytes(filename) |
| 27 zip_text = zip_data.decode(encoding) |
| 28 self.assertIn('All OK', zip_text) |
| 29 # Run the code to see that we really got it encoded properly. |
| 30 __import__("encoded_"+encoding) |
OLD | NEW |