(self, output)
| 1179 | |
| 1180 | @capture_stderr |
| 1181 | def test_multiple_handlers(self, output): |
| 1182 | structured_stream = io.StringIO() |
| 1183 | |
| 1184 | configure_logging( |
| 1185 | logger, handler_level=logging.ERROR) |
| 1186 | configure_logging( |
| 1187 | logger, level=logging.DEBUG, additive=True, |
| 1188 | output_stream=structured_stream, structured_output=True) |
| 1189 | |
| 1190 | logger.debug('debug') |
| 1191 | logger.error('error') |
| 1192 | |
| 1193 | # structured_stream has all as json, stderr only errors in text |
| 1194 | output.seek(0) |
| 1195 | error = output.readlines() |
| 1196 | self.assertEqual(len(error), 1) |
| 1197 | self.assertIn('error', error[0]) |
| 1198 | |
| 1199 | debug = list(map(json.loads, structured_stream.getvalue().splitlines())) |
| 1200 | self.assertEqual(len(debug), 2) |
| 1201 | self.assertEqual(debug[0].get('message'), 'debug') |
| 1202 | self.assertEqual(debug[1].get('message'), 'error') |
| 1203 | |
| 1204 | @capture_stderr |
| 1205 | def test_file_logging(self, output): |
nothing calls this directly
no test coverage detected