Skip to content

fix: test_update_flags and pdf encoding error #2557

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jan 19, 2023
Merged
Show file tree
Hide file tree
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: 5 additions & 4 deletions cve_bin_tool/output_engine/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -783,11 +783,12 @@ def output_file(self, output_type="console"):
self.logger.info(f"{output_type.upper()} report stored at {self.filename}")

# call to output_cves
mode = "w"
if output_type == "pdf":
mode = "wb"
with open(self.filename, mode, encoding="utf8") as f:
self.output_cves(f, output_type)
with open(self.filename, "wb") as f:
self.output_cves(f, output_type)
else:
with open(self.filename, "w", encoding="utf8") as f:
self.output_cves(f, output_type)

def check_file_path(self, filepath: str, output_type: str, prefix: str = "output"):
# check if the file already exists
Expand Down
2 changes: 1 addition & 1 deletion test/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ def test_update_flags(self):
)
with pytest.raises(SystemExit) as e:
main(["cve-bin-tool", "-u", "whatever", "-n", "json", self.tempdir])
assert e.value.args[0] == ERROR_CODES[SystemExit]
assert e.value.args[0] == 2

@staticmethod
def check_exclude_log(caplog, exclude_path, checkers):
Expand Down