collection: performance: use optimized parts function
Time: 8.53s => 5.73s
This commit is contained in:
committed by
Daniel Hahler
parent
f2cebce2eb
commit
a41820fbf0
@@ -41,6 +41,7 @@ from _pytest.mark.structures import get_unpacked_marks
|
||||
from _pytest.mark.structures import normalize_mark_list
|
||||
from _pytest.mark.structures import transfer_markers
|
||||
from _pytest.outcomes import fail
|
||||
from _pytest.pathlib import parts
|
||||
from _pytest.warning_types import PytestWarning
|
||||
from _pytest.warning_types import RemovedInPytest4Warning
|
||||
|
||||
@@ -562,14 +563,10 @@ class Package(Module):
|
||||
yield Module(init_module, self)
|
||||
pkg_prefixes = set()
|
||||
for path in this_path.visit(rec=self._recurse, bf=True, sort=True):
|
||||
# We will visit our own __init__.py file, in which case we skip it.
|
||||
if path.isfile():
|
||||
if path.basename == "__init__.py" and path.dirpath() == this_path:
|
||||
continue
|
||||
|
||||
parts = path.parts()
|
||||
parts_ = parts(path.strpath)
|
||||
if any(
|
||||
pkg_prefix in parts and pkg_prefix.join("__init__.py") != path
|
||||
pkg_prefix in parts_ and pkg_prefix.join("__init__.py") != path
|
||||
for pkg_prefix in pkg_prefixes
|
||||
):
|
||||
continue
|
||||
|
||||
Reference in New Issue
Block a user