Remove redundant Python 2.7 code

This commit is contained in:
Hugo van Kemenade 2020-10-19 10:47:35 +03:00
parent a642650e17
commit c9e5042d6d
1 changed files with 2 additions and 9 deletions

View File

@ -1,3 +1,4 @@
import importlib
import io
import operator
import os
@ -20,13 +21,6 @@ from _pytest._code.code import FormattedExcinfo
from _pytest._io import TerminalWriter
from _pytest.pytester import LineMatcher
try:
import importlib
except ImportError:
invalidate_import_caches = None
else:
invalidate_import_caches = getattr(importlib, "invalidate_caches", None)
if TYPE_CHECKING:
from _pytest._code.code import _TracebackStyle
@ -445,8 +439,7 @@ class TestFormattedExcinfo:
modpath = tmpdir.join("mod.py")
tmpdir.ensure("__init__.py")
modpath.write(source)
if invalidate_import_caches is not None:
invalidate_import_caches()
importlib.invalidate_caches()
return modpath.pyimport()
return importasmod