kopia lustrzana https://github.com/espressif/esp-idf
ttfw: allow relative imports in test scripts
rodzic
7d74cc4255
commit
3fe4adc98d
|
@ -61,11 +61,15 @@ def load_source(path):
|
||||||
return __LOADED_MODULES[path]
|
return __LOADED_MODULES[path]
|
||||||
except KeyError:
|
except KeyError:
|
||||||
try:
|
try:
|
||||||
|
dir = os.path.dirname(path)
|
||||||
|
sys.path.append(dir)
|
||||||
from importlib.machinery import SourceFileLoader
|
from importlib.machinery import SourceFileLoader
|
||||||
ret = SourceFileLoader(load_name, path).load_module()
|
ret = SourceFileLoader(load_name, path).load_module()
|
||||||
except ImportError:
|
except ImportError:
|
||||||
# importlib.machinery doesn't exists in Python 2 so we will use imp (deprecated in Python 3)
|
# importlib.machinery doesn't exists in Python 2 so we will use imp (deprecated in Python 3)
|
||||||
import imp
|
import imp
|
||||||
ret = imp.load_source(load_name, path)
|
ret = imp.load_source(load_name, path)
|
||||||
|
finally:
|
||||||
|
sys.path.remove(dir)
|
||||||
__LOADED_MODULES[path] = ret
|
__LOADED_MODULES[path] = ret
|
||||||
return ret
|
return ret
|
||||||
|
|
Ładowanie…
Reference in New Issue