pytest "INTERNALERROR>" - pytest Itself Crashed in CI
An INTERNALERROR> means pytest itself (or one of its plugins) raised an unhandled exception - during collection, hook execution, or reporting - rather than a test failing. The traceback points inside pytest or a plugin.
What this error means
The run ends with lines prefixed INTERNALERROR> and a traceback through _pytest/... or a plugin package, not your test code. No normal pass/fail summary follows because pytest crashed.
INTERNALERROR> Traceback (most recent call last):
INTERNALERROR> File ".../_pytest/main.py", line 269, in wrap_session
INTERNALERROR> File ".../pytest_randomly/__init__.py", line 200, in ...
INTERNALERROR> TypeError: object of type 'NoneType' has no len()Common causes
An incompatible plugin version
A pytest plugin out of step with the pytest version (or another plugin) raises inside a hook, crashing the whole session.
A bad conftest or hook implementation
A custom hook in conftest.py that returns the wrong type or raises during collection surfaces as an INTERNALERROR rather than a test failure.
How to fix it
Read the traceback to the offending package
- Find the deepest
INTERNALERROR>frame - it names the plugin or conftest at fault. - Pin or upgrade that plugin to a version compatible with your pytest.
- If it is your conftest hook, fix its return type/exception.
Bisect plugins to isolate the culprit
Disable plugins to find which one crashes the session.
pytest -p no:randomly # disable a suspect plugin
pytest -p no:cacheprovider # or another
# pin compatible versions once identified
pip install "pytest==8.2.*" "pytest-randomly==3.15.*"How to prevent it
- Pin pytest and its plugins to a known-compatible set.
- Upgrade pytest and plugins together, not piecemeal.
- Keep custom hooks small and well-typed; test conftest changes locally.