def test_dual(capsys): clog = DLogger("main", filename="app_simple.log", log_fmt=FORMATS[Fmt.LEVEL_MSG], cout_enabled=True, cout_level=logging.INFO) clog.debug('debug message') clog.info('info message') out, err = capsys.readouterr() assert err == "info message\n" clog.warning('warn message') _, err = capsys.readouterr() assert err == "warn message\n" clog.error('error message') _, err = capsys.readouterr() assert err == "error message\n" clog.critical('critical message') _, err = capsys.readouterr() assert err == "critical message\n" if os.getcwd().endswith('tests'): assert compare_files(path.join("test_data", "app_simple.log"), path.join("logs", "app_simple.log")) else: assert compare_files(path.join("tests", "test_data", "app_simple.log"), path.join("logs", "app_simple.log"))
def test_info_warn(): clog1 = DLogger("system", cout_fmt=FORMATS[Fmt.FNAME_LEVEL_MSG], log_level=logging.INFO, cout_level=logging.WARN, cout_enabled=True) display_details(clog1) clog1.debug('1 - msg debug') clog1.info('2 - msg info') clog1.warning('3 - msg warn') clog1.error('4 - msg error') clog1.critical('5 - msg critical') expect(no_items_in_log=4, no_items_in_cout=3)