Skip to content

Commit bb30f53

Browse files
authored
fix: test_update_flags and pdf encoding error (#2557)
* fix: test_update_flags KeyError * fix: pdf encoding error
1 parent 1d16b8c commit bb30f53

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

cve_bin_tool/output_engine/__init__.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -783,11 +783,12 @@ def output_file(self, output_type="console"):
783783
self.logger.info(f"{output_type.upper()} report stored at {self.filename}")
784784

785785
# call to output_cves
786-
mode = "w"
787786
if output_type == "pdf":
788-
mode = "wb"
789-
with open(self.filename, mode, encoding="utf8") as f:
790-
self.output_cves(f, output_type)
787+
with open(self.filename, "wb") as f:
788+
self.output_cves(f, output_type)
789+
else:
790+
with open(self.filename, "w", encoding="utf8") as f:
791+
self.output_cves(f, output_type)
791792

792793
def check_file_path(self, filepath: str, output_type: str, prefix: str = "output"):
793794
# check if the file already exists

test/test_cli.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ def test_update_flags(self):
178178
)
179179
with pytest.raises(SystemExit) as e:
180180
main(["cve-bin-tool", "-u", "whatever", "-n", "json", self.tempdir])
181-
assert e.value.args[0] == ERROR_CODES[SystemExit]
181+
assert e.value.args[0] == 2
182182

183183
@staticmethod
184184
def check_exclude_log(caplog, exclude_path, checkers):

0 commit comments

Comments
 (0)