mirror of
https://github.com/espressif/esp-idf.git
synced 2024-10-05 20:47:46 -04:00
fix(tools): Keep the original Python environment when idf_tools.py tests are run
This commit is contained in:
parent
88b40b4bea
commit
6b5b8a88db
@ -28,6 +28,7 @@ except ImportError:
|
||||
IDF_PATH = os.environ.get('IDF_PATH', '../..')
|
||||
TOOLS_DIR = os.environ.get('IDF_TOOLS_PATH') or os.path.expanduser(idf_tools.IDF_TOOLS_PATH_DEFAULT)
|
||||
PYTHON_DIR = os.path.join(TOOLS_DIR, 'python_env')
|
||||
PYTHON_DIR_BACKUP = tempfile.mkdtemp()
|
||||
REQ_SATISFIED = 'Python requirements are satisfied'
|
||||
REQ_CORE = '- {}'.format(os.path.join(IDF_PATH, 'tools', 'requirements', 'requirements.core.txt'))
|
||||
REQ_GDBGUI = '- {}'.format(os.path.join(IDF_PATH, 'tools', 'requirements', 'requirements.gdbgui.txt'))
|
||||
@ -40,6 +41,17 @@ idf_tools.global_idf_path = IDF_PATH
|
||||
idf_tools.global_idf_tools_path = TOOLS_DIR
|
||||
|
||||
|
||||
def setUpModule(): # type: () -> None
|
||||
shutil.rmtree(PYTHON_DIR_BACKUP)
|
||||
shutil.move(PYTHON_DIR, PYTHON_DIR_BACKUP)
|
||||
|
||||
|
||||
def tearDownModule(): # type: () -> None
|
||||
if os.path.isdir(PYTHON_DIR):
|
||||
shutil.rmtree(PYTHON_DIR)
|
||||
shutil.move(PYTHON_DIR_BACKUP, PYTHON_DIR)
|
||||
|
||||
|
||||
class BasePythonInstall(unittest.TestCase):
|
||||
def run_tool(self, cmd): # type: (List[str]) -> str
|
||||
ret = subprocess.run(cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, timeout=300)
|
||||
@ -262,8 +274,6 @@ class TestCheckPythonDependencies(BasePythonInstall):
|
||||
|
||||
def tearDown(self): # type: () -> None
|
||||
shutil.copyfile(self.backup_constraint_file, self.constraint_file)
|
||||
if os.path.isdir(PYTHON_DIR):
|
||||
shutil.rmtree(PYTHON_DIR)
|
||||
|
||||
def test_check_python_dependencies(self): # type: () -> None
|
||||
# Prepare artificial constraints file containing packages from
|
||||
|
Loading…
x
Reference in New Issue
Block a user