diff options
author | Ned Batchelder <ned@nedbatchelder.com> | 2014-12-13 18:47:18 -0500 |
---|---|---|
committer | Ned Batchelder <ned@nedbatchelder.com> | 2014-12-13 18:47:18 -0500 |
commit | 70a5b5cde36adbe4002f8e3f73ec0d7af31ea387 (patch) | |
tree | f4ae4dbd9b9255e31db90592704d558abe9168c6 /igor.py | |
parent | 83f2491c839ce73c085ae5e9c4bb8a345cadd5ba (diff) | |
download | python-coveragepy-70a5b5cde36adbe4002f8e3f73ec0d7af31ea387.tar.gz |
Zip files always produce bytes, and test that we get them decoded properly.
Diffstat (limited to 'igor.py')
-rw-r--r-- | igor.py | 25 |
1 files changed, 25 insertions, 0 deletions
@@ -1,3 +1,4 @@ +# coding: utf8 """Helper for building, testing, and linting coverage.py. To get portability, all these operations are written in Python here instead @@ -12,6 +13,7 @@ import os import platform import socket import sys +import textwrap import warnings import zipfile @@ -138,7 +140,30 @@ def do_test_with_tracer(tracer, *noseargs): def do_zip_mods(): """Build the zipmods.zip file.""" zf = zipfile.ZipFile("tests/zipmods.zip", "w") + + # Take one file from disk. zf.write("tests/covmodzip1.py", "covmodzip1.py") + + # The others will be various encodings. + source = textwrap.dedent(u"""\ + # coding: {encoding} + text = u"{text}" + ords = {ords} + assert [ord(c) for c in text] == ords + print(u"All OK with {encoding}") + """) + details = [ + (u'utf8', u'ⓗⓔⓛⓛⓞ, ⓦⓞⓡⓛⓓ'), + (u'gb2312', u'你好,世界'), + (u'hebrew', u'שלום, עולם'), + (u'shift_jis', u'こんにちは世界'), + ] + for encoding, text in details: + filename = 'encoded_{0}.py'.format(encoding) + ords = [ord(c) for c in text] + source_text = source.format(encoding=encoding, text=text, ords=ords) + zf.writestr(filename, source_text.encode(encoding)) + zf.close() def do_install_egg(): |