File tree Expand file tree Collapse file tree 2 files changed +3
-24
lines changed
Expand file tree Collapse file tree 2 files changed +3
-24
lines changed Original file line number Diff line number Diff line change 55
66import sys
77import os .path
8- import imp
8+ import importlib
99import zipimport
1010import functools
1111import pathlib
Original file line number Diff line number Diff line change 55
66import sys
77import pathlib
8+ import importlib
89
910import pytest
1011
@@ -17,29 +18,7 @@ def __bootstrap():
1718 This adds `python_toolbox`'s root folder to `sys.path` if it can't
1819 currently be imported.
1920 '''
20- import os
21- import sys
22- import imp
23-
24- def exists (module_name ):
25- '''
26- Return whether a module by the name `module_name` exists.
27-
28- This seems to be the best way to carefully import a module.
29-
30- Currently implemented for top-level packages only. (i.e. no dots.)
31-
32- Doesn't support modules imported from a zip file.
33- '''
34- assert '.' not in module_name
35- try :
36- imp .find_module (module_name )
37- except ImportError :
38- return False
39- else :
40- return True
41-
42- if not exists ('python_toolbox' ):
21+ if not importlib .util .find_spec ('python_toolbox' ):
4322 python_toolbox_candidate_path = \
4423 pathlib (__file__ ).parent .parent .absolute ()
4524 sys .path .append (python_toolbox_candidate_path )
You can’t perform that action at this time.
0 commit comments