(pytester: Pytester)
| 957 | |
| 958 | |
| 959 | def test_log_in_hooks(pytester: Pytester) -> None: |
| 960 | log_file = str(pytester.path.joinpath("pytest.log")) |
| 961 | |
| 962 | pytester.makeini( |
| 963 | """ |
| 964 | [pytest] |
| 965 | log_file={} |
| 966 | log_file_level = INFO |
| 967 | log_cli=true |
| 968 | """.format( |
| 969 | log_file |
| 970 | ) |
| 971 | ) |
| 972 | pytester.makeconftest( |
| 973 | """ |
| 974 | import logging |
| 975 | |
| 976 | def pytest_runtestloop(session): |
| 977 | logging.info('runtestloop') |
| 978 | |
| 979 | def pytest_sessionstart(session): |
| 980 | logging.info('sessionstart') |
| 981 | |
| 982 | def pytest_sessionfinish(session, exitstatus): |
| 983 | logging.info('sessionfinish') |
| 984 | """ |
| 985 | ) |
| 986 | result = pytester.runpytest() |
| 987 | result.stdout.fnmatch_lines(["*sessionstart*", "*runtestloop*", "*sessionfinish*"]) |
| 988 | with open(log_file) as rfh: |
| 989 | contents = rfh.read() |
| 990 | assert "sessionstart" in contents |
| 991 | assert "runtestloop" in contents |
| 992 | assert "sessionfinish" in contents |
| 993 | |
| 994 | |
| 995 | def test_log_in_runtest_logreport(pytester: Pytester) -> None: |
nothing calls this directly
no test coverage detected