diff --git a/src/_pytest/_py/path.py b/src/_pytest/_py/path.py index f51e574ce..3fc0d694b 100644 --- a/src/_pytest/_py/path.py +++ b/src/_pytest/_py/path.py @@ -1,8 +1,11 @@ """ local path implementation. """ +from __future__ import annotations + import atexit import fnmatch +import importlib.util import io import os import posixpath @@ -440,11 +443,6 @@ def map_as_list(func, iter): return list(map(func, iter)) -ALLOW_IMPORTLIB_MODE = sys.version_info > (3, 5) -if ALLOW_IMPORTLIB_MODE: - import importlib - - class Stat: def __getattr__(self, name): return getattr(self._osstatresult, "st_" + name) @@ -1110,8 +1108,6 @@ class LocalPath(FSBase): if ensuresyspath == "importlib": if modname is None: modname = self.purebasename - if not ALLOW_IMPORTLIB_MODE: - raise ImportError("Can't use importlib due to old version of Python") spec = importlib.util.spec_from_file_location(modname, str(self)) if spec is None: raise ImportError(