mirror of
https://github.com/davidhalter/jedi.git
synced 2025-12-06 14:04:26 +08:00
Make sure fixture resolving works in conftest.py, see #791
This commit is contained in:
@@ -129,11 +129,12 @@ def _iter_pytest_modules(module_context, skip_own_module=False):
|
|||||||
sys_path = module_context.inference_state.get_sys_path()
|
sys_path = module_context.inference_state.get_sys_path()
|
||||||
while any(folder.path.startswith(p) for p in sys_path):
|
while any(folder.path.startswith(p) for p in sys_path):
|
||||||
file_io = folder.get_file_io('conftest.py')
|
file_io = folder.get_file_io('conftest.py')
|
||||||
try:
|
if file_io.path != module_context.py__file__():
|
||||||
m = load_module_from_path(module_context.inference_state, file_io)
|
try:
|
||||||
yield m.as_context()
|
m = load_module_from_path(module_context.inference_state, file_io)
|
||||||
except FileNotFoundError:
|
yield m.as_context()
|
||||||
pass
|
except FileNotFoundError:
|
||||||
|
pass
|
||||||
folder = folder.get_parent_folder()
|
folder = folder.get_parent_folder()
|
||||||
|
|
||||||
for names in _PYTEST_FIXTURE_MODULES:
|
for names in _PYTEST_FIXTURE_MODULES:
|
||||||
|
|||||||
@@ -20,3 +20,10 @@ def my_not_existing_fixture():
|
|||||||
@pytest.fixture()
|
@pytest.fixture()
|
||||||
def inheritance_fixture():
|
def inheritance_fixture():
|
||||||
return ''
|
return ''
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.fixture
|
||||||
|
def testdir(testdir):
|
||||||
|
#? ['chdir']
|
||||||
|
testdir.chdir
|
||||||
|
return testdir
|
||||||
|
|||||||
@@ -206,7 +206,7 @@ class IntegrationTestCase(BaseTestCase):
|
|||||||
TEST_GOTO: self.run_goto,
|
TEST_GOTO: self.run_goto,
|
||||||
TEST_REFERENCES: self.run_find_references,
|
TEST_REFERENCES: self.run_find_references,
|
||||||
}
|
}
|
||||||
if self.path.endswith('pytest.py') \
|
if (self.path.endswith('pytest.py') or self.path.endswith('conftest.py')) \
|
||||||
and environment.executable != os.path.realpath(sys.executable):
|
and environment.executable != os.path.realpath(sys.executable):
|
||||||
# It's not guarantueed that pytest is installed in test
|
# It's not guarantueed that pytest is installed in test
|
||||||
# environments, if we're not running in the same environment that
|
# environments, if we're not running in the same environment that
|
||||||
|
|||||||
Reference in New Issue
Block a user