Skip to content

Commit 56dc01f

Browse files
committed
minor: revisit _possibly_invalidate_import_caches
1 parent 5df45f5 commit 56dc01f

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

src/_pytest/pytester.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -611,12 +611,10 @@ def syspathinsert(self, path=None):
611611
def _possibly_invalidate_import_caches(self):
612612
# invalidate caches if we can (py33 and above)
613613
try:
614-
import importlib
614+
from importlib import invalidate_caches
615615
except ImportError:
616-
pass
617-
else:
618-
if hasattr(importlib, "invalidate_caches"):
619-
importlib.invalidate_caches()
616+
return
617+
invalidate_caches()
620618

621619
def mkdir(self, name):
622620
"""Create a new (sub)directory."""

0 commit comments

Comments
 (0)