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