Skip to content

Commit 2c8b382

Browse files
committed
lib/test: show warnings and erros in case of mismatch
Show the warnings and errors of a bot if the amount does not match the expected number
1 parent f781c2c commit 2c8b382

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@
6969
- `intelmq.tests.lib.test_pipeline.TestAmqp.test_acknowledge`: Also skip on Python 3.11 and 3.12 besides on 3.8 when running on CI (PR#2542 by Sebastian Wagner).
7070
- Full pytest workflow: Version-independent install of postgres client, for Ubuntu 24.04 (default on GitHub now) test environment compatibility (PR#2557 by Sebastian Wagner).
7171
- Debian package build workflow: Use artifact upload v4 instead of v3 (PR#2565 by Sebastian Wagner).
72+
- `intelmq.lib.test.BotTestCase`: Show the warnings and errors of a bot if the amount does not match the expected number (PR#2578 by Kamil Mankowski/Sebastian Wagner, related to #2571).
7273

7374
### Tools
7475

intelmq/lib/test.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -387,9 +387,9 @@ def run_bot(self, iterations: int = 1, error_on_pipeline: bool = False,
387387
self.assertLoglineEqual(-1, "Bot stopped.", "INFO")
388388

389389
allowed_error_count = max(allowed_error_count, self.allowed_error_count)
390-
self.assertLessEqual(len(re.findall(' - ERROR - ', self.loglines_buffer)), allowed_error_count)
390+
self.assertLessEqual(len(re.findall(' - ERROR - ', self.loglines_buffer)), allowed_warning_count, "\n".join(re.findall(' - ERROR - [^\n]*', self.loglines_buffer)))
391391
allowed_warning_count = max(allowed_warning_count, self.allowed_warning_count)
392-
self.assertLessEqual(len(re.findall(' - WARNING - ', self.loglines_buffer)), allowed_warning_count)
392+
self.assertLessEqual(len(re.findall(' - WARNING - ', self.loglines_buffer)), allowed_warning_count, "\n".join(re.findall(' - WARNING - [^\n]*', self.loglines_buffer)))
393393
self.assertNotRegexpMatchesLog("CRITICAL")
394394
""" If no error happened (incl. tracebacks) we can check for formatting """
395395
if not self.allowed_error_count:

0 commit comments

Comments
 (0)