From f60c72dcf2146f0473f766203f4b10b6a774a90a Mon Sep 17 00:00:00 2001 From: guyua9 Date: Sat, 9 May 2026 20:19:25 +0800 Subject: [PATCH] fix(test): make pytest config parse on current pytest --- pyproject.toml | 5 +++-- tests/unit/test_pytest_config.py | 30 ++++++++++++++++++++++++++++++ 2 files changed, 33 insertions(+), 2 deletions(-) create mode 100644 tests/unit/test_pytest_config.py diff --git a/pyproject.toml b/pyproject.toml index a30771d..3d9813d 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -71,8 +71,9 @@ ignore = ["ANN101", "ANN102", "ANN401"] [tool.ruff.isort] known-first-party = ["rulebook_ai"] -[tool.pytest] +[tool.pytest.ini_options] testpaths = ["tests"] +pythonpath = ["src"] python_files = ["test_*.py"] python_classes = ["Test*"] python_functions = ["test_*"] @@ -80,7 +81,7 @@ markers = [ "unit: marks tests as unit tests", "integration: marks tests as integration tests", ] -addopts = "-v" +addopts = ["-v"] [tool.mypy] python_version = "3.9" diff --git a/tests/unit/test_pytest_config.py b/tests/unit/test_pytest_config.py new file mode 100644 index 0000000..038a1aa --- /dev/null +++ b/tests/unit/test_pytest_config.py @@ -0,0 +1,30 @@ +"""Regression tests for pytest configuration.""" + +import subprocess +import sys +from pathlib import Path + + +def test_pytest_config_supports_collect_only_from_repo_root() -> None: + """The pyproject pytest config should not fail during argument parsing.""" + repo_root = Path(__file__).resolve().parents[2] + + result = subprocess.run( # noqa: S603 + [ + sys.executable, + "-m", + "pytest", + "--collect-only", + "tests/unit/test_state_files.py", + "-q", + ], + cwd=repo_root, + capture_output=True, + text=True, + timeout=30, + ) + + if result.returncode != 0: + raise AssertionError(result.stderr) + if "test_state_files.py" not in result.stdout: + raise AssertionError(result.stdout)