Файли
openidea/fixtures/python-app/tests/test_fixtures.py
T
LU XIANGRUIтаwildcatDownstairs bc64188c38 feat(python): go to definition and completion for pytest fixtures (#6510)
A fixture parameter of a test or fixture now resolves to the fixture that pytest would inject: the nearest definition in the same class or module, then the conftest.py chain up to the root, pytest_plugins modules, pytest11 entry points and the _pytest builtins. Go to Declaration opens it, and completion in a test's parameter list offers the fixtures in scope with their source file. Named fixtures (name=...) and usefixtures("...") strings are covered; the fixture layers are cached by file mtime.

Closes #6490

Co-authored-by: wildcatDownstairs <[email protected]>
2026-11-27 22:12:59 +08:00

22 рядки
580 B
Python

import pytest
from tasks import Priority
class TestPending:
@pytest.fixture
def tasks(self, tasks):
# Overrides the conftest.py fixture of the same name.
tasks.add("review", Priority.NORMAL)
return tasks
def test_counts_the_extra_task(self, tasks):
assert len(tasks.pending()) == 1
@pytest.mark.usefixtures("sample")
def test_sample_is_sorted(sample, request, tmp_path):
assert [t.title for t in sample.pending()] == ["write docs", "tidy up"]
assert request.getfixturevalue("tasks") is sample
assert tmp_path.is_dir()