MCPcopy Index your code
hub / github.com/python/cpython / assert_log_lines

Method assert_log_lines

Lib/test/test_logging.py:169–185  ·  view source on GitHub ↗

Match the collected log lines against the regular expression self.expected_log_pat, and compare the extracted group values to the expected_values list of tuples.

(self, expected_values, stream=None, pat=None)

Source from the content-addressed store, hash-verified

167 threading_helper.threading_cleanup(*self._threading_key)
168
169 def assert_log_lines(self, expected_values, stream=None, pat=None):
170 """Match the collected log lines against the regular expression
171 self.expected_log_pat, and compare the extracted group values to
172 the expected_values list of tuples."""
173 stream = stream or self.stream
174 pat = re.compile(pat or self.expected_log_pat)
175 actual_lines = stream.getvalue().splitlines()
176 self.assertEqual(len(actual_lines), len(expected_values))
177 for actual, expected in zip(actual_lines, expected_values):
178 match = pat.search(actual)
179 if not match:
180 self.fail("Log line does not match expected pattern:\n" +
181 actual)
182 self.assertEqual(tuple(match.groups()), expected)
183 s = stream.read()
184 if s:
185 self.fail("Remaining output at end of log stream:\n" + s)
186
187 def next_message(self):
188 """Generate a message consisting solely of an auto-incrementing

Callers 15

test_flatMethod · 0.80
test_nested_explicitMethod · 0.80
test_nested_inheritedMethod · 0.80
test_filterMethod · 0.80
test_callable_filterMethod · 0.80
test_logger_filterMethod · 0.80
test_handler_filterMethod · 0.80
test_specific_filtersMethod · 0.80
test_flushMethod · 0.80
test_flush_on_closeMethod · 0.80

Calls 8

compileMethod · 0.45
splitlinesMethod · 0.45
getvalueMethod · 0.45
assertEqualMethod · 0.45
searchMethod · 0.45
failMethod · 0.45
groupsMethod · 0.45
readMethod · 0.45

Tested by

no test coverage detected