From 8d620d704030b06cd3deea46fec5d4cabb727797 Mon Sep 17 00:00:00 2001 From: bobo-xxx <111567133+bobo-xxx@users.noreply.github.com> Date: Sat, 18 Apr 2026 08:47:00 +0000 Subject: [PATCH] fix(tests): fix Windows test failures with click 8.2 encoding Set PYTHONIOENCODING=utf-8 environment variable for Windows platform to ensure proper Unicode handling when tests output Unicode characters through click.echo(). Fixes encoding issues that cause UnicodeEncodeError on Windows when tests output Unicode characters. --- tests/conftest.py | 8 ++++++++ tox.ini | 1 + 2 files changed, 9 insertions(+) diff --git a/tests/conftest.py b/tests/conftest.py index e50f1fe07..449ace453 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -1,4 +1,5 @@ import os +import sys import pytest from utils import ( POSTGRES_HOST, @@ -13,6 +14,13 @@ import pgcli.pgexecute +# Fix for Windows encoding issues with click 8.2+ +@pytest.fixture(autouse=True, scope="session") +def fix_windows_encoding(): + if sys.platform == "win32": + os.environ["PYTHONIOENCODING"] = "utf-8" + + @pytest.fixture(scope="function") def connection(): create_db("_test_db") diff --git a/tox.ini b/tox.ini index 1b8ea025a..5cd31b516 100644 --- a/tox.ini +++ b/tox.ini @@ -4,6 +4,7 @@ envlist = py [testenv] skip_install = true deps = uv +setenv = PYTHONIOENCODING=utf-8 commands = uv pip install -e .[dev] coverage run -m pytest -v tests coverage report -m