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

Method format

src/_pytest/logging.py:202–223  ·  view source on GitHub ↗
(self, record: logging.LogRecord)

Source from the content-addressed store, hash-verified

200 return 0
201
202 def format(self, record: logging.LogRecord) -> str:
203 if "\n" in record.message:
204 if hasattr(record, "auto_indent"):
205 # Passed in from the "extra={}" kwarg on the call to logging.log().
206 auto_indent = self._get_auto_indent(record.auto_indent)
207 else:
208 auto_indent = self._auto_indent
209
210 if auto_indent:
211 lines = record.message.splitlines()
212 formatted = self._fmt % {**record.__dict__, "message": lines[0]}
213
214 if auto_indent < 0:
215 indentation = _remove_ansi_escape_sequences(formatted).find(
216 lines[0]
217 )
218 else:
219 # Optimizes logging by allowing a fixed indentation.
220 indentation = auto_indent
221 lines[0] = formatted
222 return ("\n" + " " * indentation).join(lines)
223 return self._fmt % record.__dict__
224
225
226def get_option_ini(config: Config, *names: str):

Callers 1

test_multiline_messageFunction · 0.95

Calls 3

_get_auto_indentMethod · 0.95
joinMethod · 0.80

Tested by 1

test_multiline_messageFunction · 0.76