Summary
Four root-level files (test_api.py, test_e2e.py, test_installed_api.py, test_options_simple.py) are standalone scripts that call sys.exit() at module scope. pytest discovers them as test files and imports them, which kills the test runner process mid-collection.
Files
test_api.py
test_e2e.py
test_installed_api.py
test_options_simple.py
All four follow the same pattern:
if __name__ == "__main__":
# ...
sys.exit(0 if result else 1)
However, some also call sys.exit() at import time (not guarded by __name__ == "__main__"), or pytest imports them and the script body runs. Either way, the result is INTERNALERROR> SystemExit during collection.
Impact
- Running
pytest from the repo root causes INTERNALERROR: SystemExit before any tests execute
- The failure is silent: no test count, no failure list, just an internal crash
- CI pipelines using
pytest . or pytest without a scope argument will always fail
Recommended fix
Option A: Move these files out of pytest's discovery path. Create a scripts/ directory and relocate them there. Add scripts/ to testpaths in pytest.ini exclusions or add a conftest.py collect_ignore list.
Option B: Convert them to proper pytest test modules under tests/ with proper test functions, removing all sys.exit() calls and if __name__ == "__main__" blocks.
Option C: Add to pytest.ini:
[pytest]
collect_ignore = ["test_api.py", "test_e2e.py", "test_installed_api.py", "test_options_simple.py"]
Option B is the cleanest long-term fix.
Summary
Four root-level files (
test_api.py,test_e2e.py,test_installed_api.py,test_options_simple.py) are standalone scripts that callsys.exit()at module scope. pytest discovers them as test files and imports them, which kills the test runner process mid-collection.Files
All four follow the same pattern:
However, some also call
sys.exit()at import time (not guarded by__name__ == "__main__"), or pytest imports them and the script body runs. Either way, the result isINTERNALERROR> SystemExitduring collection.Impact
pytestfrom the repo root causesINTERNALERROR: SystemExitbefore any tests executepytest .orpytestwithout a scope argument will always failRecommended fix
Option A: Move these files out of pytest's discovery path. Create a
scripts/directory and relocate them there. Addscripts/totestpathsinpytest.iniexclusions or add aconftest.pycollect_ignorelist.Option B: Convert them to proper pytest test modules under
tests/with proper test functions, removing allsys.exit()calls andif __name__ == "__main__"blocks.Option C: Add to
pytest.ini:Option B is the cleanest long-term fix.