This answer https://stackoverflow.com/a/34920727 deals with testing log outputs
But what if I want to test that messages did not trigger, how do I do that. I am using unittest. For example:
def test_HandlerEnabled(self):
with self.assertLogs(level='DEBUG') as fake_log:
uut=myHandler.Setup(tag="foo", enabled=True, out_stream='log')
uut.Debug("testing")
self.assertEqual(fake_log.output, ["DEBUG:root:foo: testing"])
def test_HandlerDisabled(self):
with self.assertLogs(level='DEBUG') as fake_log:
uut=myHandler.Setup(tag="foo", enabled=False, out_stream='log')
uut.Debug("testing")
self.AssertThatNoLogsTriggeredOnRoot(fake_log.output) # <<<<<<<<<< here
I hereby, confirm that I have attempted to find an answer to this question myself.