enabling doctest-modules causes fixture to not be found
type: bugtype: regression
With pytest dev (starting at: 46478fad53774fad76d829f51679824d0131a0b3) the following example passes with a default pytest run but errors if `--doctest-modules` is enabled.
```python
import pytest
@pytest.fixture
def foo_fixture():
return 1
def test_foo(foo_fixture):
assert foo_fixture
```
The error is:
```
____________________________________________________________________________________________________________ ERROR at setup of test_foo _____________________________________________________________________________________________________________
file /projects/251117_pytest_dev/foo/test_foo.py, line 10
def test_foo(foo_fixture):
E fixture 'foo_fixture' not found
> available fixtures: _syrupy_apply_ide_patches, cache, capfd, capfdbinary, caplog, capsys, capsysbinary, capteesys, doctest_namespace, monkeypatch, pytestconfig, record_property, record_testsuite_property, record_xml_attribute, recwarn, snapshot, subtests, tmp_path, tmp_path_factory, tmpdir, tmpdir_factory
> use 'pytest --fixtures [testpath]' for help on them.
/projects/251117_pytest_dev/foo/test_foo.py:10
```
The prior commit (543b11f2534bb0edc85b86767ed239da9c5bd140) passes in with `--doctest-modules`.
<details>
<summary>pip list</summary>
```
Package Version Editable project location
----------------- ----------------------- ------------------------------------------------
aiohappyeyeballs 2.6.2
aiohttp 3.13.5
aiosignal 1.4.0
asdf 5.3.1.dev86+g71187c0fc /projects/251117_pytest_dev/asdf
asdf_standard 1.5.0
attrs 26.1.0
frozenlist 1.8.0
fsspec 2026.4.0
idna 3.17
iniconfig 2.3.0
jmespath 1.1.0
lz4 4.4.5
multidict 6.7.1
numpy 2.4.6
packaging 25.0
pip 24.0
pluggy 1.6.0
propcache 0.5.2
psutil 7.2.2
Pygments 2.19.2
pytest 9.1.0.dev386+g46478fad5 /projects/251117_pytest_dev/pytest
PyYAML 6.0.3
semantic-version 2.10.0
syrupy 5.2.0
typing_extensions 4.15.0
yarl 1.24.2
```
</details>
Tested with pytest dev (commits above) mac os.
- [x] a detailed description of the bug or problem you are having
- [x] output of `pip list` from the virtual environment you are using
- [x] pytest and operating system versions
- [x] minimal example if possible
5 条评论