Skip to content

Commit b49d118

Browse files
authored
Fix logging error with emoji in git branch name. (#2790)
Resolves #2768
1 parent c838192 commit b49d118

File tree

4 files changed

+5
-3
lines changed

4 files changed

+5
-3
lines changed

docs/changelog/2768.bugfix.rst

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fix logging error with emoji in git branch name.

src/tox/pytest.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ def _setup_files(dest: Path, base: Path | None, content: dict[str, Any]) -> None
161161
at_path.mkdir(exist_ok=True)
162162
ToxProject._setup_files(at_path, None, value)
163163
elif isinstance(value, str):
164-
at_path.write_text(textwrap.dedent(value))
164+
at_path.write_text(textwrap.dedent(value), encoding="utf-8")
165165
elif value is None:
166166
at_path.mkdir()
167167
else:

src/tox/tox_env/api.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -444,7 +444,7 @@ def _log_execute(self, request: ExecuteRequest, status: ExecuteStatus) -> None:
444444

445445
@staticmethod
446446
def _write_execute_log(env_name: str, log_file: Path, request: ExecuteRequest, status: ExecuteStatus) -> None:
447-
with log_file.open("wt") as file:
447+
with log_file.open("wt", encoding="utf-8") as file:
448448
file.write(f"name: {env_name}\n")
449449
file.write(f"run_id: {request.run_id}\n")
450450
for env_key, env_value in request.env.items():

tests/tox_env/test_tox_env_api.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@ def test_allow_list_external_fail(tox_project: ToxProjectCreator, fake_exe_on_pa
3434

3535
def test_env_log(tox_project: ToxProjectCreator) -> None:
3636
cmd = "commands=python -c 'import sys; print(1); print(2); print(3, file=sys.stderr); print(4, file=sys.stderr)'"
37-
prj = tox_project({"tox.ini": f"[testenv]\npackage=skip\n{cmd}"})
37+
env_vars = " UNPREDICTABLE = 🪟"
38+
prj = tox_project({"tox.ini": f"[testenv]\npackage=skip\nset_env =\n{env_vars}\n{cmd}"})
3839
result_first = prj.run("r")
3940
result_first.assert_success()
4041

0 commit comments

Comments
 (0)