@@ -259,34 +259,22 @@ def collect(self):
259
259
260
260
if filepath in ("setup.py" , "__main__.py" ):
261
261
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
+
263
267
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 )
267
269
elif PYTEST_GT_5 :
268
- module = self .config .pluginmanager ._importconftest (
269
- self .fspath , self .config .getoption ("importmode" ))
270
+ module = import_path (fspath , mode = mode )
270
271
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
290
278
291
279
options = get_optionflags (self ) | FIX
292
280
0 commit comments