MCPcopy Create free account
hub / github.com/pytest-dev/pytest / test_log_file_unicode

Function test_log_file_unicode

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

Source from the content-addressed store, hash-verified

784
785
786def test_log_file_unicode(pytester: Pytester) -> None:
787 log_file = str(pytester.path.joinpath("pytest.log"))
788
789 pytester.makeini(
790 """
791 [pytest]
792 log_file={}
793 log_file_level = INFO
794 """.format(
795 log_file
796 )
797 )
798 pytester.makepyfile(
799 """\
800 import logging
801
802 def test_log_file():
803 logging.getLogger('catchlog').info("Normal message")
804 logging.getLogger('catchlog').info("├")
805 logging.getLogger('catchlog').info("Another normal message")
806 """
807 )
808
809 result = pytester.runpytest()
810
811 # make sure that we get a '0' exit code for the testsuite
812 assert result.ret == 0
813 assert os.path.isfile(log_file)
814 with open(log_file, encoding="utf-8") as rfh:
815 contents = rfh.read()
816 assert "Normal message" in contents
817 assert "├" in contents
818 assert "Another normal message" in contents
819
820
821@pytest.mark.parametrize("has_capture_manager", [True, False])

Callers

nothing calls this directly

Calls 5

makeiniMethod · 0.45
formatMethod · 0.45
makepyfileMethod · 0.45
runpytestMethod · 0.45
readMethod · 0.45

Tested by

no test coverage detected