mirror of
https://gitflic.ru/project/openide/openide.git
synced 2025-12-18 08:50:57 +07:00
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.
(cherry picked from commit 2d9a5dd6bd34d1c06d47b3587cd365696642ccd7)
IJ-MR-167570
GitOrigin-RevId: 709f080d6c23d1f76ad397cb6363e74623758cfd
10 lines
313 B
Python
10 lines
313 B
Python
def calculate_fixtures():
|
|
# Imitate custom logic around collecting folders.
|
|
# For the real-world examples see PY-71370
|
|
fixtures_folder = "fixtures"
|
|
subdirectories = ["first", "second"]
|
|
return [f"{fixtures_folder}.{subdir}" for subdir in subdirectories]
|
|
|
|
|
|
pytest_plugins = calculate_fixtures()
|