diff options
author | James Williams <james@kananlabs.org> | 2022-12-29 17:33:56 -0600 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-12-29 15:33:56 -0800 |
commit | b49d11867ab6bd7219c5b2c50f610e7829395975 (patch) | |
tree | a674bb40db2862aeafdc3abb929c72b1ed16c450 | |
parent | c83819262b4b739899af8a0bd7b6f32442344e4a (diff) | |
download | tox-git-b49d11867ab6bd7219c5b2c50f610e7829395975.tar.gz |
Fix logging error with emoji in git branch name. (#2790)
Resolves https://github.com/tox-dev/tox/issues/2768
-rw-r--r-- | docs/changelog/2768.bugfix.rst | 1 | ||||
-rw-r--r-- | src/tox/pytest.py | 2 | ||||
-rw-r--r-- | src/tox/tox_env/api.py | 2 | ||||
-rw-r--r-- | tests/tox_env/test_tox_env_api.py | 3 |
4 files changed, 5 insertions, 3 deletions
diff --git a/docs/changelog/2768.bugfix.rst b/docs/changelog/2768.bugfix.rst new file mode 100644 index 00000000..80623b62 --- /dev/null +++ b/docs/changelog/2768.bugfix.rst @@ -0,0 +1 @@ +Fix logging error with emoji in git branch name. diff --git a/src/tox/pytest.py b/src/tox/pytest.py index 21cd816a..ae211252 100644 --- a/src/tox/pytest.py +++ b/src/tox/pytest.py @@ -161,7 +161,7 @@ class ToxProject: at_path.mkdir(exist_ok=True) ToxProject._setup_files(at_path, None, value) elif isinstance(value, str): - at_path.write_text(textwrap.dedent(value)) + at_path.write_text(textwrap.dedent(value), encoding="utf-8") elif value is None: at_path.mkdir() else: diff --git a/src/tox/tox_env/api.py b/src/tox/tox_env/api.py index 98c4501a..3ce15b99 100644 --- a/src/tox/tox_env/api.py +++ b/src/tox/tox_env/api.py @@ -444,7 +444,7 @@ class ToxEnv(ABC): @staticmethod def _write_execute_log(env_name: str, log_file: Path, request: ExecuteRequest, status: ExecuteStatus) -> None: - with log_file.open("wt") as file: + with log_file.open("wt", encoding="utf-8") as file: file.write(f"name: {env_name}\n") file.write(f"run_id: {request.run_id}\n") for env_key, env_value in request.env.items(): diff --git a/tests/tox_env/test_tox_env_api.py b/tests/tox_env/test_tox_env_api.py index f4f28607..1a8fefdc 100644 --- a/tests/tox_env/test_tox_env_api.py +++ b/tests/tox_env/test_tox_env_api.py @@ -34,7 +34,8 @@ def test_allow_list_external_fail(tox_project: ToxProjectCreator, fake_exe_on_pa def test_env_log(tox_project: ToxProjectCreator) -> None: cmd = "commands=python -c 'import sys; print(1); print(2); print(3, file=sys.stderr); print(4, file=sys.stderr)'" - prj = tox_project({"tox.ini": f"[testenv]\npackage=skip\n{cmd}"}) + env_vars = " UNPREDICTABLE = 🪟" + prj = tox_project({"tox.ini": f"[testenv]\npackage=skip\nset_env =\n{env_vars}\n{cmd}"}) result_first = prj.run("r") result_first.assert_success() |