File tree Expand file tree Collapse file tree 1 file changed +2
-9
lines changed Expand file tree Collapse file tree 1 file changed +2
-9
lines changed Original file line number Diff line number Diff line change
1
+ import importlib
1
2
import io
2
3
import operator
3
4
import os
20
21
from _pytest ._io import TerminalWriter
21
22
from _pytest .pytester import LineMatcher
22
23
23
- try :
24
- import importlib
25
- except ImportError :
26
- invalidate_import_caches = None
27
- else :
28
- invalidate_import_caches = getattr (importlib , "invalidate_caches" , None )
29
-
30
24
if TYPE_CHECKING :
31
25
from _pytest ._code .code import _TracebackStyle
32
26
@@ -445,8 +439,7 @@ def importasmod(source):
445
439
modpath = tmpdir .join ("mod.py" )
446
440
tmpdir .ensure ("__init__.py" )
447
441
modpath .write (source )
448
- if invalidate_import_caches is not None :
449
- invalidate_import_caches ()
442
+ importlib .invalidate_caches ()
450
443
return modpath .pyimport ()
451
444
452
445
return importasmod
You can’t perform that action at this time.
0 commit comments