Files
openide/python/testData/testPytestFixtureResolving
Ilia Zakoulov 763147c873 PY-71370: Resolve any suitable fixture candidate if pytest_plugins cannot be parsed
This bug was introduced during a refactoring of fixture support.
While the correct order of resolution was maintained, it relied on the assumption that pytest_plugins could be statically analyzed.

Consider the following example:
```python
import os
from glob import iglob

DIR_PATH = os.path.dirname(os.path.abspath(__file__))

def create_pytest_plugins():
    # Dynamically resolves fixture plugin names by scanning the fixtures directory
    fixture_names = _make_fixture_names("tests/utils/fixtures/**/*.py")
    return fixture_names

def _make_fixture_names(fixture_path_pattern: str):
    os.chdir(f"{DIR_PATH}/../../")
    return [
        _make_fixture_name(fixture_path)
        for fixture_path in iglob(fixture_path_pattern, recursive=True)
        if "__" not in fixture_path
    ]

def _make_fixture_name(fixture_path: str) -> str:
    return fixture_path.replace("/", ".").replace(".py", "")

pytest_plugins = create_pytest_plugins()
```
In such cases, where pytest_plugins is resolved dynamically and cannot be parsed statically, it is preferable to fall back to resolving any other suitable fixture found in the project, rather than skipping resolution altogether.

GitOrigin-RevId: 54f3739da114825f7543896910c1e17073ed5a96
2025-07-01 17:10:16 +00:00
..