[DEV] Cross platform test fixture helpers (#1058)

This commit is contained in:
Jesse Bannon 2024-09-20 14:58:07 -07:00 committed by GitHub
parent 6510fd0999
commit 3fbdd26257
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 4 additions and 5 deletions

View file

@ -15,14 +15,12 @@ _EXPECTED_DOWNLOADS_SUMMARY_PATH = RESOURCE_PATH / "expected_downloads_summaries
def _get_files_in_directory(relative_directory: Path | str) -> List[Path]:
relative_path_part_idx = 3 # Cuts /tmp/<tmp_folder>
if IS_WINDOWS:
relative_path_part_idx = 7 # Cuts C:\Users\<user>\AppData\Local\Temp\<tmp_folder>
relative_file_paths: List[Path] = []
for path in Path(relative_directory).rglob("*"):
if path.is_file():
relative_path = Path(*path.parts[relative_path_part_idx:])
relative_path = Path(
str(path).removeprefix(str(relative_directory)).removeprefix(os.path.sep)
)
relative_file_paths.append(relative_path)
return relative_file_paths

View file

@ -133,6 +133,7 @@ class TestLogger:
except ValueError as exc:
Logger.log_exception(exception=exc)
time.sleep(0.1) # flush time
Logger.cleanup(has_error=has_error)
assert not os.path.isfile(Logger.debug_log_filename())