File tree Expand file tree Collapse file tree 1 file changed +7
-3
lines changed Expand file tree Collapse file tree 1 file changed +7
-3
lines changed Original file line number Diff line number Diff line change @@ -538,14 +538,18 @@ def pytest_runtest_logreport(
538
538
pytest_collectreport = pytest_runtest_logreport
539
539
540
540
def isinitpath (self , path : Union [str , "os.PathLike[str]" ]) -> bool :
541
- return Path (path ) in self ._initialpaths
541
+ # Optimization: Path(Path(...)) is much slower than isinstance.
542
+ path_ = path if isinstance (path , Path ) else Path (path )
543
+ return path_ in self ._initialpaths
542
544
543
545
def gethookproxy (self , fspath : "os.PathLike[str]" ):
546
+ # Optimization: Path(Path(...)) is much slower than isinstance.
547
+ path = fspath if isinstance (fspath , Path ) else Path (fspath )
548
+ pm = self .config .pluginmanager
544
549
# Check if we have the common case of running
545
550
# hooks with all conftest.py files.
546
- pm = self .config .pluginmanager
547
551
my_conftestmodules = pm ._getconftestmodules (
548
- Path ( fspath ) ,
552
+ path ,
549
553
self .config .getoption ("importmode" ),
550
554
rootpath = self .config .rootpath ,
551
555
)
You can’t perform that action at this time.
0 commit comments