Skip to content

Commit

Permalink
fix(tools): Keep the original Python environment when idf_tools.py te…
Browse files Browse the repository at this point in the history
…sts are run
  • Loading branch information
dobairoland committed Aug 7, 2023
1 parent 88b40b4 commit 6b5b8a8
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions tools/test_idf_tools/test_idf_tools_python_env.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
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'))
Expand All @@ -40,6 +41,17 @@
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)
Expand Down Expand Up @@ -262,8 +274,6 @@ def setUp(self): # type: () -> None

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
Expand Down

0 comments on commit 6b5b8a8

Please sign in to comment.