Skip to content

Commit 68682b3

Browse files
committed
minor: revisit _possibly_invalidate_import_caches
1 parent 02667ba commit 68682b3

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
@@ -609,12 +609,10 @@ def syspathinsert(self, path=None):
609609
def _possibly_invalidate_import_caches(self):
610610
# invalidate caches if we can (py33 and above)
611611
try:
612-
import importlib
612+
from importlib import invalidate_caches
613613
except ImportError:
614-
pass
615-
else:
616-
if hasattr(importlib, "invalidate_caches"):
617-
importlib.invalidate_caches()
614+
return
615+
invalidate_caches()
618616

619617
def mkdir(self, name):
620618
"""Create a new (sub)directory."""

0 commit comments

Comments
 (0)