@@ -259,34 +259,22 @@ def collect(self):
259259
260260 if filepath in ("setup.py" , "__main__.py" ):
261261 return
262- elif filepath == "conftest.py" :
262+ try :
263+ if PYTEST_GT_5 :
264+ from _pytest .pathlib import import_path
265+ mode = self .config .getoption ("importmode" )
266+
263267 if PYTEST_GE_7_0 :
264- module = self .config .pluginmanager ._importconftest (
265- self .path , self .config .getoption ("importmode" ),
266- rootpath = self .config .rootpath )
268+ module = import_path (fspath , mode = mode , root = self .config .rootpath )
267269 elif PYTEST_GT_5 :
268- module = self .config .pluginmanager ._importconftest (
269- self .fspath , self .config .getoption ("importmode" ))
270+ module = import_path (fspath , mode = mode )
270271 else :
271- module = self .config .pluginmanager ._importconftest (
272- self .fspath )
273- else :
274- try :
275- if PYTEST_GT_5 :
276- from _pytest .pathlib import import_path
277- mode = self .config .getoption ("importmode" )
278-
279- if PYTEST_GE_7_0 :
280- module = import_path (fspath , mode = mode , root = self .config .rootpath )
281- elif PYTEST_GT_5 :
282- module = import_path (fspath , mode = mode )
283- else :
284- module = fspath .pyimport ()
285- except ImportError :
286- if self .config .getvalue ("doctest_ignore_import_errors" ):
287- pytest .skip ("unable to import module %r" % fspath )
288- else :
289- raise
272+ module = fspath .pyimport ()
273+ except ImportError :
274+ if self .config .getvalue ("doctest_ignore_import_errors" ):
275+ pytest .skip ("unable to import module %r" % fspath )
276+ else :
277+ raise
290278
291279 options = get_optionflags (self ) | FIX
292280
0 commit comments