Using with pytest#

logot includes a pytest plugin. Just use the logot fixture in your tests:

from logot import Logot, logged

def test_my_app(logot: Logot) -> None:
   app.start()
   logot.wait_for(logged.info("App started"))

Note

The logot fixture is configured with default settings and captures all logs in the root logger.

See also

See Logot API reference for default settings.

Customizing the logot fixture#

To customize the logot fixure, simply override it in your own conftest.py:

import pytest
from logot import Logot, logged

@pytest.fixture()
def logot():
   with Logot(timeout=30.0).capturing(level=logging.WARNING) as logot:
      yield logot

See also

See Logot and Logot.capturing() API reference.