Example #1
0
def test_open_log(tmp_path):
    log_file = tmp_path / "test.log"
    log.open_log(log_file)

    with on_time('2018-04-15 16:50', 'CET'):
        log.logger.warning("abc")
        log.logger.warning("äbc")

    with log_file.open("rb") as f:
        assert f.read() == (b"2018-04-15 18:50:00,000 [30] [cmk] abc\n"
                            b"2018-04-15 18:50:00,000 [30] [cmk] \xc3\xa4bc\n")
Example #2
0
def test_open_log(tmp_path):
    log_file = tmp_path / "test.log"
    log.open_log(log_file)

    with on_time('2018-04-15 16:50', 'CET'):
        log.logger.warning("abc")
        log.logger.warning(u"äbc")
        # With python 3 we do not have the implicit conversion from byte strings
        # to text strings anymore: No need to test this.
        if sys.version_info[0] >= 3:
            log.logger.warning("äbc")
        else:
            log.logger.warning(b"\xc3\xa4bc")

    with log_file.open("rb") as f:
        assert f.read() == \
            b"2018-04-15 18:50:00,000 [30] [cmk] abc\n" \
            b"2018-04-15 18:50:00,000 [30] [cmk] \xc3\xa4bc\n" \
            b"2018-04-15 18:50:00,000 [30] [cmk] \xc3\xa4bc\n"