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

Function test_multiline_message

testing/logging/test_formatter.py:62–148  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

60
61
62def test_multiline_message() -> None:
63 from _pytest.logging import PercentStyleMultiline
64
65 logfmt = "%(filename)-25s %(lineno)4d %(levelname)-8s %(message)s"
66
67 record: Any = logging.LogRecord(
68 name="dummy",
69 level=logging.INFO,
70 pathname="dummypath",
71 lineno=10,
72 msg="Test Message line1\nline2",
73 args=(),
74 exc_info=None,
75 )
76 # this is called by logging.Formatter.format
77 record.message = record.getMessage()
78
79 ai_on_style = PercentStyleMultiline(logfmt, True)
80 output = ai_on_style.format(record)
81 assert output == (
82 "dummypath 10 INFO Test Message line1\n"
83 " line2"
84 )
85
86 ai_off_style = PercentStyleMultiline(logfmt, False)
87 output = ai_off_style.format(record)
88 assert output == (
89 "dummypath 10 INFO Test Message line1\nline2"
90 )
91
92 ai_none_style = PercentStyleMultiline(logfmt, None)
93 output = ai_none_style.format(record)
94 assert output == (
95 "dummypath 10 INFO Test Message line1\nline2"
96 )
97
98 record.auto_indent = False
99 output = ai_on_style.format(record)
100 assert output == (
101 "dummypath 10 INFO Test Message line1\nline2"
102 )
103
104 record.auto_indent = True
105 output = ai_off_style.format(record)
106 assert output == (
107 "dummypath 10 INFO Test Message line1\n"
108 " line2"
109 )
110
111 record.auto_indent = "False"
112 output = ai_on_style.format(record)
113 assert output == (
114 "dummypath 10 INFO Test Message line1\nline2"
115 )
116
117 record.auto_indent = "True"
118 output = ai_off_style.format(record)
119 assert output == (

Callers

nothing calls this directly

Calls 2

formatMethod · 0.95

Tested by

no test coverage detected