Skip to content

Commit 4cc5438

Browse files
authored
fix(test): switch --nvd option to JSON for broken long tests (#1425)
* ci: switch nvd option to json for long tests * ci: update to latest CVE data for long tests every run * fix(test): `test_update` and `test_update_flags`
1 parent 9d866e3 commit 4cc5438

File tree

2 files changed

+22
-9
lines changed

2 files changed

+22
-9
lines changed

.github/workflows/pythonapp.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ jobs:
176176
- name: try single cli run of tool
177177
run: |
178178
python -m pip install -e .
179-
NO_EXIT_CVE_NUM=1 python -m cve_bin_tool.cli test/assets
179+
NO_EXIT_CVE_NUM=1 python -m cve_bin_tool.cli test/assets -n json -u latest
180180
- name: Run async tests
181181
run: >
182182
pytest --cov --cov-append -n 4 -v

test/test_cli.py

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -122,11 +122,20 @@ def test_invalid_parameter(self):
122122

123123
@unittest.skipUnless(LONG_TESTS() > 0, "Skipping long tests")
124124
def test_update_flags(self):
125-
assert main(["cve-bin-tool", "-x", "-u", "never", self.tempdir]) != 0
126-
assert main(["cve-bin-tool", "-x", "--update", "daily", self.tempdir]) != 0
127-
assert main(["cve-bin-tool", "-x", "-u", "now", self.tempdir]) != 0
125+
assert (
126+
main(["cve-bin-tool", "-x", "-u", "never", "-n", "json", self.tempdir]) != 0
127+
)
128+
assert (
129+
main(
130+
["cve-bin-tool", "-x", "--update", "daily", "-n", "json", self.tempdir]
131+
)
132+
!= 0
133+
)
134+
assert (
135+
main(["cve-bin-tool", "-x", "-u", "now", "-n", "json", self.tempdir]) != 0
136+
)
128137
with pytest.raises(SystemExit) as e:
129-
main(["cve-bin-tool", "-u", "whatever", self.tempdir])
138+
main(["cve-bin-tool", "-u", "whatever", "-n", "json", self.tempdir])
130139
assert e.value.args[0] == -2
131140

132141
@staticmethod
@@ -194,7 +203,7 @@ def test_update(self, caplog):
194203
test_path = os.path.join(os.path.abspath(os.path.dirname(__file__)), "csv")
195204

196205
with caplog.at_level(logging.INFO):
197-
main(["cve-bin-tool", "-u", "never", test_path])
206+
main(["cve-bin-tool", "-u", "never", "-n", "json", test_path])
198207
assert (
199208
"cve_bin_tool",
200209
logging.WARNING,
@@ -203,7 +212,9 @@ def test_update(self, caplog):
203212
caplog.clear()
204213

205214
with caplog.at_level(logging.DEBUG):
206-
main(["cve-bin-tool", "-l", "debug", "-u", "daily", test_path])
215+
main(
216+
["cve-bin-tool", "-l", "debug", "-u", "daily", "-n", "json", test_path]
217+
)
207218
assert (
208219
"cve_bin_tool.CVEDB",
209220
logging.INFO,
@@ -216,7 +227,7 @@ def test_update(self, caplog):
216227
caplog.clear()
217228

218229
with caplog.at_level(logging.DEBUG):
219-
main(["cve-bin-tool", "-l", "debug", "-u", "now", test_path])
230+
main(["cve-bin-tool", "-l", "debug", "-u", "now", "-n", "json", test_path])
220231
db_path = DISK_LOCATION_DEFAULT
221232
assert (
222233
"cve_bin_tool.CVEDB",
@@ -230,7 +241,9 @@ def test_update(self, caplog):
230241
caplog.clear()
231242

232243
with caplog.at_level(logging.DEBUG):
233-
main(["cve-bin-tool", "-l", "debug", "-u", "latest", test_path])
244+
main(
245+
["cve-bin-tool", "-l", "debug", "-u", "latest", "-n", "json", test_path]
246+
)
234247
assert (
235248
"cve_bin_tool.CVEDB",
236249
logging.DEBUG,

0 commit comments

Comments
 (0)