(self, output)
| 1203 | |
| 1204 | @capture_stderr |
| 1205 | def test_file_logging(self, output): |
| 1206 | with tempfile.TemporaryDirectory() as dir: |
| 1207 | logfile = os.path.join(dir, "out.log") |
| 1208 | |
| 1209 | configure_logging(logger, output_file=logfile) |
| 1210 | |
| 1211 | logger.error('test-msg') |
| 1212 | |
| 1213 | # log msg is in the log file |
| 1214 | with open(logfile, "r") as fp: |
| 1215 | self.assertIn('test-msg', fp.read()) |
| 1216 | |
| 1217 | # there're no logs on stderr |
| 1218 | output.seek(0) |
| 1219 | self.assertEqual(output.read(), '') |
| 1220 | |
| 1221 | # reset log config to enable temp dir cleanup |
| 1222 | configure_logging(logger) |
| 1223 | |
| 1224 | |
| 1225 | class TestLoggingHelpers(unittest.TestCase): |
nothing calls this directly
no test coverage detected