def test_basic_log(self, capsys): logger = Loggable("loggable_test") logger.set_level("INFO") logger.track("INFO").info("log2") log, _ = capsys.readouterr() assert "INFO" in log
def test_not_enabled(self): logger = Loggable("loggable_test") logger.set_level("CRITICAL") track = logger.track("INFO") assert not track.is_enabled() track = logger.track("CRITICAL") assert track.is_enabled()
def test_update(self, capsys): logger = Loggable("loggable_test") logger.set_level("INFO") track = logger.track("INFO", total=100).enter() track.update(10, "10% there!") track.update(20, "20% there!") track.exit()
def test_no_update(self, capsys): logger = Loggable("loggable_test") logger.set_level("CRITICAL") assert not logger.is_enabled("INFO") track = logger.track("INFO", total=100).enter() track.update(10, "10% there!") track.update(20, "20% there!") track.exit()
def test_exception_is_raised_for_track(self): logger = Loggable("test loggable") with pytest.raises(ValueError) as e: with logger.track("ERROR", 100): raise ValueError
def test_track_iterable(self): logger = Loggable("loggable_test") logger.set_level("INFO") track = logger.track("INFO", desc="This is a progress bar") for x in track(range(10)): track.info(x)