pathlib: replace py.path.local.visit() with our own function

Part of reducing dependency on `py`. Also enables upcoming improvements.

In cases where there are simpler alternatives (in tests), I used those.

What's left are a couple of uses in `_pytest.main` and `_pytest.python`
and they only have modest requirements, so all of the featureful code
from py is not needed.
This commit is contained in:
Ran Benita
2020-07-05 22:58:47 +03:00
parent 3a060b77e8
commit c15bb5d3de
6 changed files with 30 additions and 15 deletions

View File

@@ -65,6 +65,7 @@ from _pytest.outcomes import skip
from _pytest.pathlib import import_path
from _pytest.pathlib import ImportPathMismatchError
from _pytest.pathlib import parts
from _pytest.pathlib import visit
from _pytest.reports import TerminalRepr
from _pytest.warning_types import PytestCollectionWarning
from _pytest.warning_types import PytestUnhandledCoroutineWarning
@@ -641,7 +642,7 @@ class Package(Module):
):
yield Module.from_parent(self, fspath=init_module)
pkg_prefixes = set() # type: Set[py.path.local]
for path in this_path.visit(rec=self._recurse, bf=True, sort=True):
for path in visit(this_path, recurse=self._recurse):
# We will visit our own __init__.py file, in which case we skip it.
is_file = path.isfile()
if is_file: