Skip to content

Commit 95203a2

Browse files
BillionClawBillionClaw
andauthored
fix(tests): Fix Windows test failures related to click 8.2 encoding issues (#1560)
Windows uses CP1252 encoding by default, which cannot handle Unicode characters output by click.echo(). This causes test failures on Windows when using click 8.2+. This fix sets PYTHONIOENCODING=utf-8 in: - tests/conftest.py: Set at module level for Windows platform - tox.ini: Set via setenv for all test environments Fixes encoding issues that cause UnicodeEncodeError on Windows when tests output Unicode characters through click.echo(). Co-authored-by: BillionClaw <billionclaw+clawoss@users.noreply.github.com>
1 parent b5bc102 commit 95203a2

2 files changed

Lines changed: 15 additions & 0 deletions

File tree

tests/conftest.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import os
2+
import platform
23
import pytest
34
from utils import (
45
POSTGRES_HOST,
@@ -13,6 +14,13 @@
1314
import pgcli.pgexecute
1415

1516

17+
# Fix Windows test failures related to click 8.2 encoding issues
18+
# Windows uses CP1252 encoding by default, which can't handle Unicode characters
19+
# Set PYTHONIOENCODING=utf-8 to ensure proper Unicode handling
20+
if platform.system() == "Windows":
21+
os.environ.setdefault("PYTHONIOENCODING", "utf-8")
22+
23+
1624
@pytest.fixture(scope="function")
1725
def connection():
1826
create_db("_test_db")

tox.ini

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ passenv = PGHOST
1111
PGPORT
1212
PGUSER
1313
PGPASSWORD
14+
PYTHONIOENCODING
15+
setenv =
16+
PYTHONIOENCODING = utf-8
1417

1518
[testenv:style]
1619
skip_install = true
@@ -23,6 +26,10 @@ skip_install = true
2326
deps = uv
2427
commands = uv pip install -e .[dev]
2528
behave tests/features --no-capture
29+
passenv =
30+
PYTHONIOENCODING
31+
setenv =
32+
PYTHONIOENCODING = utf-8
2633

2734
[testenv:rest]
2835
skip_install = true

0 commit comments

Comments
 (0)