diff --git a/pyproject.toml b/pyproject.toml index 51c2f7f8..fdfb407a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -63,7 +63,7 @@ Documentation = "https://codeentropy.readthedocs.io" testing = [ "pytest>=9.0,<10.0", "pytest-cov>=7.0,<8.0", - "pytest-sugar>=1.1,<2.0", + "pytest-modern>=0.7.5,<0.8.0", ] pre-commit = [ "pre-commit>=3.5.0,<5.0", @@ -84,11 +84,16 @@ CodeEntropy = "CodeEntropy.cli:main" [tool.pytest.ini_options] testpaths = ["tests"] -addopts = "-vv -ra" +addopts = [ + "-vv", + "-ra", + "--cov", + "--cov-report=term-missing", +] markers = [ - "regression: end-to-end regression tests against baselines", - "slow: long-running regression tests (20-30+ minutes)", + "regression: end-to-end regression tests against baselines", + "slow: long-running regression tests (20-30+ minutes)", ] [tool.ruff] diff --git a/tests/conftest.py b/tests/conftest.py new file mode 100644 index 00000000..46bf53c1 --- /dev/null +++ b/tests/conftest.py @@ -0,0 +1,19 @@ +from __future__ import annotations + +import sys + +import pytest + + +@pytest.hookimpl(tryfirst=True) +def pytest_configure(config): + """ + Force UTF-8 output for the terminal reporter. + + On Windows CI stdout is a pipe using cp1252, and pytest-modern crashes + when it writes characters that cp1252 can't encode. This has to run + before pytest-modern sets up its console. + """ + for stream in (sys.stdout, sys.stderr): + if hasattr(stream, "reconfigure") and stream.encoding.lower() != "utf-8": + stream.reconfigure(encoding="utf-8", errors="backslashreplace")