MCPcopy
hub / github.com/pytest-dev/pytest / test_log_file_unicode

Function test_log_file_unicode

testing/logging/test_reporting.py:892–922  ·  view source on GitHub ↗
(pytester: Pytester)

Source from the content-addressed store, hash-verified

890
891
892def test_log_file_unicode(pytester: Pytester) -> None:
893 log_file = str(pytester.path.joinpath("pytest.log"))
894
895 pytester.makeini(
896 f"""
897 [pytest]
898 log_file={log_file}
899 log_file_level = INFO
900 """
901 )
902 pytester.makepyfile(
903 """\
904 import logging
905
906 def test_log_file():
907 logging.getLogger('catchlog').info("Normal message")
908 logging.getLogger('catchlog').info("├")
909 logging.getLogger('catchlog').info("Another normal message")
910 """
911 )
912
913 result = pytester.runpytest()
914
915 # make sure that we get a '0' exit code for the testsuite
916 assert result.ret == 0
917 assert os.path.isfile(log_file)
918 with open(log_file, encoding="utf-8") as rfh:
919 contents = rfh.read()
920 assert "Normal message" in contents
921 assert "├" in contents
922 assert "Another normal message" in contents
923
924
925@pytest.mark.parametrize("has_capture_manager", [True, False])

Callers

nothing calls this directly

Calls 5

makeiniMethod · 0.45
makepyfileMethod · 0.45
runpytestMethod · 0.45
isfileMethod · 0.45
readMethod · 0.45

Tested by

no test coverage detected