diff options
author | Ran Benita <ran@unusedvar.com> | 2020-07-05 22:58:47 +0300 |
---|---|---|
committer | Ran Benita <ran@unusedvar.com> | 2020-07-25 00:26:49 +0300 |
commit | c15bb5d3de084a10ade0a99e2f6ec1226aa9356a (patch) | |
tree | 0785a32a3b1256194827d99c3d30f9af58f20f20 /src/_pytest/main.py | |
parent | 3a060b77e81ebf990159e59cc8f8de26ad998e12 (diff) | |
download | pytest-c15bb5d3de084a10ade0a99e2f6ec1226aa9356a.tar.gz |
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.
Diffstat (limited to 'src/_pytest/main.py')
-rw-r--r-- | src/_pytest/main.py | 13 |
1 files changed, 5 insertions, 8 deletions
diff --git a/src/_pytest/main.py b/src/_pytest/main.py index 7e6816506..7f81c341d 100644 --- a/src/_pytest/main.py +++ b/src/_pytest/main.py @@ -32,6 +32,7 @@ from _pytest.config.argparsing import Parser from _pytest.fixtures import FixtureManager from _pytest.outcomes import exit from _pytest.pathlib import Path +from _pytest.pathlib import visit from _pytest.reports import CollectReport from _pytest.reports import TestReport from _pytest.runner import collect_one_node @@ -617,9 +618,10 @@ class Session(nodes.FSCollector): assert not names, "invalid arg {!r}".format((argpath, names)) seen_dirs = set() # type: Set[py.path.local] - for path in argpath.visit( - fil=self._visit_filter, rec=self._recurse, bf=True, sort=True - ): + for path in visit(argpath, self._recurse): + if not path.check(file=1): + continue + dirpath = path.dirpath() if dirpath not in seen_dirs: # Collect packages first. @@ -668,11 +670,6 @@ class Session(nodes.FSCollector): return yield from m - @staticmethod - def _visit_filter(f: py.path.local) -> bool: - # TODO: Remove type: ignore once `py` is typed. - return f.check(file=1) # type: ignore - def _tryconvertpyarg(self, x: str) -> str: """Convert a dotted module name to path.""" try: |