diff options
author | Anthony Sottile <asottile@umich.edu> | 2019-03-31 18:39:24 -0700 |
---|---|---|
committer | Bernát Gábor <gaborjbernat@gmail.com> | 2019-04-01 02:39:24 +0100 |
commit | 566b6b6e6db1a54e3adb94f6fe11664fb243505d (patch) | |
tree | 1c2c6adc5b6d8cfd78674993a296c1aaaa6f67ea | |
parent | 4cd761017ec0fc8ccff650ef7db2cca9dbec5073 (diff) | |
download | tox-git-566b6b6e6db1a54e3adb94f6fe11664fb243505d.tar.gz |
Read file lines as text in python2 as well (#1237)
-rw-r--r-- | docs/changelog/1234.bugfix.rst | 1 | ||||
-rw-r--r-- | src/tox/action.py | 2 | ||||
-rw-r--r-- | tests/unit/test_z_cmdline.py | 19 |
3 files changed, 21 insertions, 1 deletions
diff --git a/docs/changelog/1234.bugfix.rst b/docs/changelog/1234.bugfix.rst new file mode 100644 index 00000000..53d4de32 --- /dev/null +++ b/docs/changelog/1234.bugfix.rst @@ -0,0 +1 @@ +Fix sdist creation on python2.x when there is non-ascii output. diff --git a/src/tox/action.py b/src/tox/action.py index bcc722f6..10707b48 100644 --- a/src/tox/action.py +++ b/src/tox/action.py @@ -104,7 +104,7 @@ class Action(object): exit_code = process.returncode finally: if out_path is not None and out_path.exists(): - lines = out_path.read().split("\n") + lines = out_path.read_text("UTF-8").split("\n") # first three lines are the action, cwd, and cmd - remove it output = "\n".join(lines[3:]) try: diff --git a/tests/unit/test_z_cmdline.py b/tests/unit/test_z_cmdline.py index 9b0d6e43..ed889809 100644 --- a/tests/unit/test_z_cmdline.py +++ b/tests/unit/test_z_cmdline.py @@ -805,6 +805,25 @@ def test_env_VIRTUALENV_PYTHON(initproj, cmd, monkeypatch): assert "create" in result.out +def test_setup_prints_non_ascii(initproj, cmd): + initproj( + "example123", + filedefs={ + "setup.py": """\ +import sys +getattr(sys.stdout, 'buffer', sys.stdout).write(b'\\xe2\\x98\\x83\\n') + +import setuptools +setuptools.setup(name='example123') +""", + "tox.ini": "", + }, + ) + result = cmd("--notest") + result.assert_success() + assert "create" in result.out + + def test_envsitepackagesdir(cmd, initproj): initproj( "pkg512-0.0.5", |