Skip to content

Commit

Permalink
Fix logging error with emoji in git branch name. (#2790)
Browse files Browse the repository at this point in the history
Resolves #2768
  • Loading branch information
jamwil committed Dec 29, 2022
1 parent c838192 commit b49d118
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 3 deletions.
1 change: 1 addition & 0 deletions docs/changelog/2768.bugfix.rst
@@ -0,0 +1 @@
Fix logging error with emoji in git branch name.
2 changes: 1 addition & 1 deletion src/tox/pytest.py
Expand Up @@ -161,7 +161,7 @@ def _setup_files(dest: Path, base: Path | None, content: dict[str, Any]) -> None
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:
Expand Down
2 changes: 1 addition & 1 deletion src/tox/tox_env/api.py
Expand Up @@ -444,7 +444,7 @@ def _log_execute(self, request: ExecuteRequest, status: ExecuteStatus) -> None:

@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():
Expand Down
3 changes: 2 additions & 1 deletion tests/tox_env/test_tox_env_api.py
Expand Up @@ -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()

Expand Down

0 comments on commit b49d118

Please sign in to comment.