conftest.py 432 B

123456789101112131415
  1. import logging
  2. import pytest
  3. import unittest.mock
  4. from cipy import _handler
  5. @pytest.fixture(scope="function")
  6. def ci_logger(monkeypatch: pytest.MonkeyPatch) -> unittest.mock.Mock:
  7. mock = unittest.mock.Mock(spec=logging.Formatter)
  8. monkeypatch.setattr(_handler, "formatter", mock)
  9. level = logging.getLogger().level
  10. logging.getLogger().setLevel(logging.NOTSET)
  11. yield mock
  12. logging.getLogger().setLevel(level)