Skip to content

Commit

Permalink
fix(test): Allow tests using '--output-dir' to run multiple times
Browse files Browse the repository at this point in the history
The pytest fixture varies both the name of the temporary directory and
the parents of it. By only handling the name of the directory, we had a
conflict when we run the test multiple times in a row.
  • Loading branch information
m-horky committed Dec 19, 2024
1 parent a7388c4 commit cc1b195
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions integration-tests/test_collection.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@

import contextlib
import os
import pathlib
import shutil
import tarfile
import json
import pytest
Expand Down Expand Up @@ -298,10 +300,9 @@ def test_branch_info(insights_client, test_config, subman, tmp_path):
1. The branch_info file is generated
2. The branch_info includes correct values
"""
insights_client.run("--output-dir", tmp_path.name)

branch_info_path: str = os.path.join(tmp_path.name, "branch_info")
with open(branch_info_path, "r") as file:
insights_client.run("--output-dir", tmp_path.absolute())
branch_info_path = tmp_path / "branch_info"
with branch_info_path.open("r") as file:
data = json.load(file)

if "satellite" in test_config.environment:
Expand Down Expand Up @@ -352,13 +353,11 @@ def test_archive_structure(insights_client, tmp_path):
"usr",
]

insights_client.run("--output-dir", tmp_path.name)

extracted_dirs_files = os.listdir(tmp_path.name) # type: list[str]
insights_client.run("--output-dir", tmp_path.absolute())
extracted_dirs_files = os.listdir(tmp_path) # type: list[str]
missing_dirs = [f for f in archive_content if f not in extracted_dirs_files]
assert not missing_dirs, f"Missing directories {missing_dirs}"

data_dir_path = os.path.join(tmp_path.name, "data")
data_subdirs = os.listdir(data_dir_path) # type: list[str]
data_subdirs = os.listdir(tmp_path / "data") # type: list[str]
missing_subdirs = [f for f in archive_data_content if f not in data_subdirs]
assert not missing_subdirs, f"Missing subdirectory {missing_subdirs}"

0 comments on commit cc1b195

Please sign in to comment.