Esempio n. 1
0
    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
Esempio n. 2
0
    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()
Esempio n. 3
0
    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()
Esempio n. 4
0
    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()
Esempio n. 5
0
 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
Esempio n. 6
0
 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)