minor: revisit _possibly_invalidate_import_caches

This commit is contained in:
Daniel Hahler 2019-03-22 16:29:02 +01:00
parent 5df45f5b27
commit 56dc01ffe0
1 changed files with 3 additions and 5 deletions

View File

@ -611,12 +611,10 @@ class Testdir(object):
def _possibly_invalidate_import_caches(self):
# invalidate caches if we can (py33 and above)
try:
import importlib
from importlib import invalidate_caches
except ImportError:
pass
else:
if hasattr(importlib, "invalidate_caches"):
importlib.invalidate_caches()
return
invalidate_caches()
def mkdir(self, name):
"""Create a new (sub)directory."""