I did take a look at it looks this was reported before a while ago: #11045 But that suggests that it was only only python 3.12 dev but I'm having this problem on 3.11,3.12,3.13,and 3.14.
That test was added when I was using pytest 7 and I'm now using pytest 9 so it's been consistently broken for pytest 7, 8, and 9.
For this test: https://github.com/taverntesting/tavern/blob/55e592546f0ea7354c7a72e8a1a34cb03c325318/tests/unit/test_skip.py#L96-L107 (when commenting out the xfail) I always get:
tests/unit/test_skip.py:104: in test_skip_invalid_simpleeval
with caplog.at_level(logging.WARNING):
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
../../.local/share/uv/python/cpython-3.14.0-linux-x86_64-gnu/lib/python3.14/contextlib.py:141: in __enter__
return next(self.gen)
^^^^^^^^^^^^^^
.tox/py314/lib/python3.14/site-packages/_pytest/logging.py:568: in at_level
handler_orig_level = self.handler.level
^^^^^^^^^^^^
.tox/py314/lib/python3.14/site-packages/_pytest/logging.py:434: in handler
return self._item.stash[caplog_handler_key]
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
.tox/py314/lib/python3.14/site-packages/_pytest/stash.py:84: in __getitem__
return cast(T, self._storage[key])
^^^^^^^^^^^^^^^^^^
E KeyError: <_pytest.stash.StashKey object at 0x7f9405c914c0>
If I change that function it's testing to raise an error instead and use pytest.Raises:
with pytest.raises(exceptions.EvalError):
_run_test(stage, test_block_config, run_mock)
assert "unable to parse as simpleeval" in caplog.text
Then the same issue happens in the assert ... in caplog.text
tests/unit/test_skip.py:108: in test_skip_invalid_simpleeval
assert "unable to parse as simpleeval" in caplog.text
^^^^^^^^^^^
.venv/lib64/python3.13/site-packages/_pytest/logging.py:454: in text
return _remove_ansi_escape_sequences(self.handler.stream.getvalue())
^^^^^^^^^^^^
.venv/lib64/python3.13/site-packages/_pytest/logging.py:434: in handler
return self._item.stash[caplog_handler_key]
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
.venv/lib64/python3.13/site-packages/_pytest/stash.py:84: in __getitem__
return cast(T, self._storage[key])
^^^^^^^^^^^^^^^^^^
E KeyError: <_pytest.stash.StashKey object at 0x7ffaa3c1e9a0>
I admit I might be using caplog wrong here but I wouldn't expect it to raise a weird error like this.
I was trying to get a minimal repro but I couldn't, but anyone can check out the repo at that commit and it should show the same behaviour for that test.
Pip environment:
Pip environment
Package Version Editable project location
aiohappyeyeballs 2.6.1
aiohttp 3.13.5
aiosignal 1.4.0
allure-pytest 2.15.3
allure-python-commons 2.15.3
annotated-doc 0.0.4
annotated-types 0.7.0
anyio 4.13.0
attrs 26.1.0
backoff 2.2.1
blinker 1.9.0
cachetools 7.0.5
certifi 2026.2.25
cffi 2.0.0
cfgv 3.5.0
charset-normalizer 3.4.7
cli-ui 0.19.0
click 8.3.2
colorama 0.4.6
colorlog 6.10.1
coverage 7.13.5
cross-web 0.4.1
cryptography 46.0.7
distlib 0.4.0
docopt 0.6.2
docutils 0.22.4
exceptiongroup 1.3.1
execnet 2.1.2
Faker 40.13.0
fastapi 0.135.3
filelock 3.25.2
Flask 3.1.3
flit 3.12.0
flit_core 3.12.0
fluent-logger 0.11.1
frozenlist 1.8.0
google-api-core 2.30.3
google-api-python-client 2.194.0
google-auth 2.49.2
google-auth-httplib2 0.3.1
googleapis-common-protos 1.74.0
gql 4.0.0
graphql-core 3.2.8
greenlet 3.4.0
grpc-interceptor 0.15.4
grpcio 1.80.0
grpcio-reflection 1.71.2
grpcio-status 1.71.2
grpcio-tools 1.71.2
gunicorn 25.3.0
h11 0.16.0
httplib2 0.31.2
httptools 0.7.1
hypothesis 6.151.12
identify 2.6.18
idna 3.11
iniconfig 2.3.0
itsdangerous 2.2.0
Jinja2 3.1.6
jmespath 1.1.0
jsonschema 4.26.0
jsonschema-specifications 2025.9.1
MarkupSafe 3.0.3
msgpack 1.1.2
multidict 6.7.1
nodeenv 1.10.0
packaging 26.0
paho-mqtt 1.6.1
pbr 7.0.3
pip 26.0.1
platformdirs 4.9.6
pluggy 1.6.0
pre_commit 4.5.1
propcache 0.4.1
proto-plus 1.27.2
protobuf 5.29.6
protobuf-protoc-bin 29.5
py 1.11.0
pyasn1 0.6.3
pyasn1_modules 0.4.2
pycparser 3.0
pydantic 2.12.5
pydantic_core 2.41.5
Pygments 2.20.0
PyJWT 2.12.1
pykwalify 1.8.0
pyparsing 3.3.2
pyproject-api 1.10.0
pytest 9.0.3
pytest-asyncio 1.3.0
pytest-cov 7.1.0
pytest-xdist 3.8.0
python-box 6.1.0
python-dateutil 2.9.0.post0
python-discovery 1.2.2
python-dotenv 1.2.2
python-multipart 0.0.26
PyYAML 6.0.3
referencing 0.37.0
requests 2.33.1
rpds-py 0.30.0
ruamel.yaml 0.18.17
ruamel.yaml.clib 0.2.15
ruff 0.9.10
schema 0.7.8
sentinel 1.0.0
setuptools 82.0.1
simpleeval 1.0.7
six 1.17.0
sortedcontainers 2.4.0
sqlakeyset 2.0.1775222100
SQLAlchemy 2.0.49
starlette 1.0.0
stevedore 4.1.1
strawberry-graphql 0.314.3
strawberry-sqlalchemy-mapper 0.8.0
tabulate 0.9.0
tavern 3.3.3 /home/michael/code/tavern
tavern_graphql_example 0.1.0 /home/michael/code/tavern/example/graphql
tavern_grpc_example 0.1.0 /home/michael/code/tavern/example/grpc
tavern_http_example 0.1.0 /home/michael/code/tavern/example/http
tavern_mqtt_example 0.1.0 /home/michael/code/tavern/example/mqtt
tbump 6.11.0
tomli 2.4.1
tomli_w 1.2.0
tomlkit 0.11.8
tox 4.52.1
tox-uv 1.35.1
tox-uv-bare 1.35.1
types-jmespath 1.1.0.20260408
types-jsonschema 4.26.0.20260408
types-paho-mqtt 1.6.0.20240321
types-protobuf 5.29.1.20250403
types-PyYAML 6.0.12.20260408
types-requests 2.33.0.20260408
typing_extensions 4.15.0
typing-inspection 0.4.2
Unidecode 1.4.0
uritemplate 4.2.0
urllib3 2.6.3
uv 0.11.6
uvicorn 0.44.0
uvloop 0.22.1
virtualenv 21.2.1
watchfiles 1.1.1
websockets 16.0
Werkzeug 3.1.8
wheel 0.46.3
yarl 1.23.0
I did take a look at it looks this was reported before a while ago: #11045 But that suggests that it was only only python 3.12 dev but I'm having this problem on 3.11,3.12,3.13,and 3.14.
That test was added when I was using pytest 7 and I'm now using pytest 9 so it's been consistently broken for pytest 7, 8, and 9.
For this test: https://github.com/taverntesting/tavern/blob/55e592546f0ea7354c7a72e8a1a34cb03c325318/tests/unit/test_skip.py#L96-L107 (when commenting out the xfail) I always get:
If I change that function it's testing to raise an error instead and use pytest.Raises:
Then the same issue happens in the
assert ... in caplog.textI admit I might be using caplog wrong here but I wouldn't expect it to raise a weird error like this.
I was trying to get a minimal repro but I couldn't, but anyone can check out the repo at that commit and it should show the same behaviour for that test.
Pip environment:
Pip environment
Package Version Editable project location
aiohappyeyeballs 2.6.1
aiohttp 3.13.5
aiosignal 1.4.0
allure-pytest 2.15.3
allure-python-commons 2.15.3
annotated-doc 0.0.4
annotated-types 0.7.0
anyio 4.13.0
attrs 26.1.0
backoff 2.2.1
blinker 1.9.0
cachetools 7.0.5
certifi 2026.2.25
cffi 2.0.0
cfgv 3.5.0
charset-normalizer 3.4.7
cli-ui 0.19.0
click 8.3.2
colorama 0.4.6
colorlog 6.10.1
coverage 7.13.5
cross-web 0.4.1
cryptography 46.0.7
distlib 0.4.0
docopt 0.6.2
docutils 0.22.4
exceptiongroup 1.3.1
execnet 2.1.2
Faker 40.13.0
fastapi 0.135.3
filelock 3.25.2
Flask 3.1.3
flit 3.12.0
flit_core 3.12.0
fluent-logger 0.11.1
frozenlist 1.8.0
google-api-core 2.30.3
google-api-python-client 2.194.0
google-auth 2.49.2
google-auth-httplib2 0.3.1
googleapis-common-protos 1.74.0
gql 4.0.0
graphql-core 3.2.8
greenlet 3.4.0
grpc-interceptor 0.15.4
grpcio 1.80.0
grpcio-reflection 1.71.2
grpcio-status 1.71.2
grpcio-tools 1.71.2
gunicorn 25.3.0
h11 0.16.0
httplib2 0.31.2
httptools 0.7.1
hypothesis 6.151.12
identify 2.6.18
idna 3.11
iniconfig 2.3.0
itsdangerous 2.2.0
Jinja2 3.1.6
jmespath 1.1.0
jsonschema 4.26.0
jsonschema-specifications 2025.9.1
MarkupSafe 3.0.3
msgpack 1.1.2
multidict 6.7.1
nodeenv 1.10.0
packaging 26.0
paho-mqtt 1.6.1
pbr 7.0.3
pip 26.0.1
platformdirs 4.9.6
pluggy 1.6.0
pre_commit 4.5.1
propcache 0.4.1
proto-plus 1.27.2
protobuf 5.29.6
protobuf-protoc-bin 29.5
py 1.11.0
pyasn1 0.6.3
pyasn1_modules 0.4.2
pycparser 3.0
pydantic 2.12.5
pydantic_core 2.41.5
Pygments 2.20.0
PyJWT 2.12.1
pykwalify 1.8.0
pyparsing 3.3.2
pyproject-api 1.10.0
pytest 9.0.3
pytest-asyncio 1.3.0
pytest-cov 7.1.0
pytest-xdist 3.8.0
python-box 6.1.0
python-dateutil 2.9.0.post0
python-discovery 1.2.2
python-dotenv 1.2.2
python-multipart 0.0.26
PyYAML 6.0.3
referencing 0.37.0
requests 2.33.1
rpds-py 0.30.0
ruamel.yaml 0.18.17
ruamel.yaml.clib 0.2.15
ruff 0.9.10
schema 0.7.8
sentinel 1.0.0
setuptools 82.0.1
simpleeval 1.0.7
six 1.17.0
sortedcontainers 2.4.0
sqlakeyset 2.0.1775222100
SQLAlchemy 2.0.49
starlette 1.0.0
stevedore 4.1.1
strawberry-graphql 0.314.3
strawberry-sqlalchemy-mapper 0.8.0
tabulate 0.9.0
tavern 3.3.3 /home/michael/code/tavern
tavern_graphql_example 0.1.0 /home/michael/code/tavern/example/graphql
tavern_grpc_example 0.1.0 /home/michael/code/tavern/example/grpc
tavern_http_example 0.1.0 /home/michael/code/tavern/example/http
tavern_mqtt_example 0.1.0 /home/michael/code/tavern/example/mqtt
tbump 6.11.0
tomli 2.4.1
tomli_w 1.2.0
tomlkit 0.11.8
tox 4.52.1
tox-uv 1.35.1
tox-uv-bare 1.35.1
types-jmespath 1.1.0.20260408
types-jsonschema 4.26.0.20260408
types-paho-mqtt 1.6.0.20240321
types-protobuf 5.29.1.20250403
types-PyYAML 6.0.12.20260408
types-requests 2.33.0.20260408
typing_extensions 4.15.0
typing-inspection 0.4.2
Unidecode 1.4.0
uritemplate 4.2.0
urllib3 2.6.3
uv 0.11.6
uvicorn 0.44.0
uvloop 0.22.1
virtualenv 21.2.1
watchfiles 1.1.1
websockets 16.0
Werkzeug 3.1.8
wheel 0.46.3
yarl 1.23.0
pip listfrom the virtual environment you are using