Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions test/test_scanner.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,10 @@ def teardown_class(cls):
shutil.rmtree(cls.package_test_dir)
shutil.rmtree(cls.mapping_test_dir)

def windows_fixup(self, filename):
"""Replace colon and backslash in filename to avoid a failure on Windows"""
return filename.replace(":", "_").replace("\\", "_")

def test_false_positive(self):
self.scanner.all_cves = []
with tempfile.NamedTemporaryFile(
Expand Down Expand Up @@ -148,10 +152,9 @@ def test_version_mapping(self, product, version, version_strings):
f"{'.'.join(list(product))}-{version}.out",
]
for filename in filenames:
# Replace colon and backslash in filename to avoid a failure on Windows
with tempfile.NamedTemporaryFile(
"w+b",
suffix=filename.replace(":", "_").replace("\\", "_"),
suffix=self.windows_fixup(filename),
dir=self.mapping_test_dir,
delete=False,
) as f:
Expand Down Expand Up @@ -234,7 +237,7 @@ def condensed_filepath(self, url, package_name):
dirpath.mkdir()
# Check if we've already made a condensed version of the file, if we
# have, we're done.
condensed_path = condensed_dir / (package_name + ".tar.gz")
condensed_path = condensed_dir / (self.windows_fixup(package_name) + ".tar.gz")
if condensed_path.is_file():
return str(condensed_path)
# Download the file if we don't have a condensed version of it and we
Expand Down
Loading