diff options
author | Andras Mitzki <andras.mitzki@balabit.com> | 2019-02-20 16:51:09 +0100 |
---|---|---|
committer | Andras Mitzki <andras.mitzki@balabit.com> | 2019-02-22 05:14:44 +0100 |
commit | b26b73149897e7dda9910d8e3a153c7d586aedec (patch) | |
tree | 9e2eb5d422571ac905074e38eba215a187010269 /testing/logging | |
parent | c8a87e48ab8673286fdddf710000bcb11b813160 (diff) | |
download | pytest-b26b73149897e7dda9910d8e3a153c7d586aedec.tar.gz |
Logging: Make pytest_runtest_logreport() available for logging
Signed-off-by: Andras Mitzki <andras.mitzki@balabit.com>
Diffstat (limited to 'testing/logging')
-rw-r--r-- | testing/logging/test_reporting.py | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/testing/logging/test_reporting.py b/testing/logging/test_reporting.py index afeccfcc5..90db8813e 100644 --- a/testing/logging/test_reporting.py +++ b/testing/logging/test_reporting.py @@ -1004,6 +1004,40 @@ def test_log_in_hooks(testdir): assert "sessionfinish" in contents +def test_log_in_runtest_logreport(testdir): + log_file = testdir.tmpdir.join("pytest.log").strpath + + testdir.makeini( + """ + [pytest] + log_file={} + log_file_level = INFO + log_cli=true + """.format( + log_file + ) + ) + testdir.makeconftest( + """ + import logging + logger = logging.getLogger(__name__) + + def pytest_runtest_logreport(report): + logger.info("logreport") + """ + ) + testdir.makepyfile( + """ + def test_first(): + assert True + """ + ) + testdir.runpytest() + with open(log_file) as rfh: + contents = rfh.read() + assert contents.count("logreport") == 3 + + def test_log_set_path(testdir): report_dir_base = testdir.tmpdir.strpath |