diff --git a/src/_pytest/config/__init__.py b/src/_pytest/config/__init__.py index 68c3822d0..bb5034ab1 100644 --- a/src/_pytest/config/__init__.py +++ b/src/_pytest/config/__init__.py @@ -23,7 +23,6 @@ from typing import Union import attr import py -from packaging.version import Version from pluggy import HookimplMarker from pluggy import HookspecMarker from pluggy import PluginManager @@ -1059,6 +1058,9 @@ class Config: minver = self.inicfg.get("minversion", None) if minver: + # Imported lazily to improve start-up time. + from packaging.version import Version + if Version(minver) > Version(pytest.__version__): raise pytest.UsageError( "%s:%d: requires pytest-%s, actual pytest-%s'" diff --git a/src/_pytest/nodes.py b/src/_pytest/nodes.py index 448e67127..2f5f9bdb8 100644 --- a/src/_pytest/nodes.py +++ b/src/_pytest/nodes.py @@ -456,10 +456,7 @@ def _check_initialpaths_for_relpath(session, fspath): class FSHookProxy: - def __init__( - self, fspath: py.path.local, pm: PytestPluginManager, remove_mods - ) -> None: - self.fspath = fspath + def __init__(self, pm: PytestPluginManager, remove_mods) -> None: self.pm = pm self.remove_mods = remove_mods @@ -510,7 +507,7 @@ class FSCollector(Collector): remove_mods = pm._conftest_plugins.difference(my_conftestmodules) if remove_mods: # one or more conftests are not in use at this fspath - proxy = FSHookProxy(fspath, pm, remove_mods) + proxy = FSHookProxy(pm, remove_mods) else: # all plugins are active for this fspath proxy = self.config.hook diff --git a/src/_pytest/outcomes.py b/src/_pytest/outcomes.py index 7d7e9df7a..751cf9474 100644 --- a/src/_pytest/outcomes.py +++ b/src/_pytest/outcomes.py @@ -9,8 +9,6 @@ from typing import cast from typing import Optional from typing import TypeVar -from packaging.version import Version - TYPE_CHECKING = False # avoid circular import through compat if TYPE_CHECKING: @@ -217,6 +215,9 @@ def importorskip( return mod verattr = getattr(mod, "__version__", None) if minversion is not None: + # Imported lazily to improve start-up time. + from packaging.version import Version + if verattr is None or Version(verattr) < Version(minversion): raise Skipped( "module %r has __version__ %r, required is: %r" diff --git a/src/_pytest/terminal.py b/src/_pytest/terminal.py index 3de0612bf..8ecb5a16b 100644 --- a/src/_pytest/terminal.py +++ b/src/_pytest/terminal.py @@ -443,8 +443,7 @@ class TerminalReporter: self.write_ensure_prefix(line, "") self.flush() elif self.showfspath: - fsid = nodeid.split("::")[0] - self.write_fspath_result(fsid, "") + self.write_fspath_result(nodeid, "") self.flush() def pytest_runtest_logreport(self, report: TestReport) -> None: @@ -474,10 +473,7 @@ class TerminalReporter: else: markup = {} if self.verbosity <= 0: - if not running_xdist and self.showfspath: - self.write_fspath_result(rep.nodeid, letter, **markup) - else: - self._tw.write(letter, **markup) + self._tw.write(letter, **markup) else: self._progress_nodeids_reported.add(rep.nodeid) line = self._locationline(rep.nodeid, *rep.location)