Skip to content

Commit 2eb58b5

Browse files
committed
test: Be more lax when checking logs
When increasing the log-level or when adding more logging, it can easily happen that new messages are logged during tests. Usually we only want to check that a particular log appeared, not that no other log did. Signed-off-by: Leandro Lucarella <[email protected]>
1 parent 115f882 commit 2eb58b5

File tree

1 file changed

+7
-9
lines changed

1 file changed

+7
-9
lines changed

tests/timeseries/test_resampling.py

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -156,16 +156,14 @@ async def test_helper_buffer_too_big(
156156

157157
_ = helper.resample(datetime.now(timezone.utc))
158158
# Ignore errors produced by wrongly finalized gRPC server in unrelated tests
159-
assert _filter_logs(
159+
assert (
160+
"frequenz.sdk.timeseries._resampling",
161+
logging.ERROR,
162+
f"The new buffer length ({DEFAULT_BUFFER_LEN_MAX + 1}) "
163+
f"for timeseries test is too big, using {DEFAULT_BUFFER_LEN_MAX} instead",
164+
) in _filter_logs(
160165
caplog.record_tuples,
161-
) == [
162-
(
163-
"frequenz.sdk.timeseries._resampling",
164-
logging.ERROR,
165-
f"The new buffer length ({DEFAULT_BUFFER_LEN_MAX + 1}) "
166-
f"for timeseries test is too big, using {DEFAULT_BUFFER_LEN_MAX} instead",
167-
)
168-
]
166+
)
169167
# pylint: disable=protected-access
170168
assert helper._buffer.maxlen == DEFAULT_BUFFER_LEN_MAX
171169

0 commit comments

Comments
 (0)