Skip to content

Commit 61c08e4

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 806d81e commit 61c08e4

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
@@ -107,6 +107,7 @@ Please refer to the [NEWS](NEWS.md) for a list of changes which have an affect o
107107
- `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).
108108
- 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).
109109
- Debian package build workflow: Use artifact upload v4 instead of v3 (PR#2565 by Sebastian Wagner).
110+
- `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).
110111

111112
### Known issues
112113
This is short list of the most important known issues. The full list can be retrieved from [GitHub](https://github.com/certtools/intelmq/labels/bug?page=2&q=is%3Aopen+label%3Abug).

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)