Closed
Description
Especially during testing of a new release, I often comment out dependencies and add collect_ignore_glob = ["test_*.py"]
to conftest
to skip test collection for a whole block for tests which depend on in incompatible dependency. With Python 3.14 the evaluation of annotations is deferred by default, so pytest shouldn't throw an error if a name is undefined. A similar result could previously be archived by adding from __future__ import annotations
.
# test.py
import pytest
# from incompatible_dependency import X
@pytest.fixture
def some_obj() -> X:
...
def test_func(some_obj) -> None:
assert True
pytest test.py
test.py:8: in __annotate__
def some_obj() -> X:
^
E NameError: name 'X' is not defined
As far as I'm aware, pytest doesn't care about annotations. A possible solution would be to add a compatibility layer to the inspect.signature
call with annotation_format=Format.STRING
as added argument. In particular here:
Line 125 in 9f9b7f4
Metadata
Metadata
Assignees
Labels
No labels