diff --git a/tests/conftest.py b/tests/conftest.py index e50f1fe07..3a989f8b3 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -1,4 +1,5 @@ import os +import platform import pytest from utils import ( POSTGRES_HOST, @@ -13,6 +14,13 @@ import pgcli.pgexecute +# Fix Windows test failures related to click 8.2 encoding issues +# Windows uses CP1252 encoding by default, which can't handle Unicode characters +# Set PYTHONIOENCODING=utf-8 to ensure proper Unicode handling +if platform.system() == "Windows": + os.environ.setdefault("PYTHONIOENCODING", "utf-8") + + @pytest.fixture(scope="function") def connection(): create_db("_test_db") diff --git a/tox.ini b/tox.ini index 1b8ea025a..5ef2db01c 100644 --- a/tox.ini +++ b/tox.ini @@ -11,6 +11,9 @@ passenv = PGHOST PGPORT PGUSER PGPASSWORD + PYTHONIOENCODING +setenv = + PYTHONIOENCODING = utf-8 [testenv:style] skip_install = true @@ -23,6 +26,10 @@ skip_install = true deps = uv commands = uv pip install -e .[dev] behave tests/features --no-capture +passenv = + PYTHONIOENCODING +setenv = + PYTHONIOENCODING = utf-8 [testenv:rest] skip_install = true