Skip to content

Commit

Permalink
Improve Logger test coverage.
Browse files Browse the repository at this point in the history
  • Loading branch information
edtechre committed Feb 15, 2023
1 parent 8fb6214 commit 2015940
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion tests/test_log.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,31 @@

from .fixtures import * # noqa: F401
from pybroker.log import Logger
import logging


class TestLogger:
def test_enable_and_disable(scope, capsys):
def test_enable_and_disable(scope, capsys, caplog):
caplog.set_level(logging.DEBUG)
logger = Logger(scope)
logger.disable()
logger.indicator_data_start([])
logger.info_indicator_data_start([])
logger.debug_compute_indicators(is_parallel=False)
logger.loaded_indicator_data()
logger.warn_bootstrap_sample_size(10, 100)
assert capsys.readouterr() == ("", "")
assert not caplog.record_tuples
logger.enable()
logger.indicator_data_start([])
logger.info_indicator_data_start([])
logger.debug_compute_indicators(is_parallel=False)
logger.loaded_indicator_data()
logger.warn_bootstrap_sample_size(10, 100)
captured = capsys.readouterr()
assert captured.out
assert captured.err == ""
assert len(caplog.record_tuples) == 3

def test_enable_and_disable_progress_bar(scope, capsys):
logger = Logger(scope)
Expand Down

0 comments on commit 2015940

Please sign in to comment.