Using with unittest#

logot includes logot.unittest.LogotTestCase for easy integration with unittest.

The logot attribute automatically captures logs during tests and can be used to make log assertions:

from logot import logged
from logot.unittest import LogotTestCase

class MyAppTest(LogotTestCase):

   def test_something(self) -> None:
      do_something()
      self.logot.assert_logged(logged.info("App started"))

Configuring#

Override logot-prefixed attributes in your test case to configure the logot attribute:

class MyAppTest(LogotTestCase):
   logot_level = "WARNING"
   logot_name = "app"
   logot_timeout = 10.0

See also

See logot.unittest.LogotTestCase API reference.