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

Function test_code_highlight

testing/io/test_terminalwriter.py:298–311  ·  view source on GitHub ↗
(has_markup, code_highlight, expected, color_mapping)

Source from the content-addressed store, hash-verified

296 ],
297)
298def test_code_highlight(has_markup, code_highlight, expected, color_mapping):
299 f = io.StringIO()
300 tw = terminalwriter.TerminalWriter(f)
301 tw.hasmarkup = has_markup
302 tw.code_highlight = code_highlight
303 tw._write_source(["assert 0"])
304
305 assert f.getvalue().splitlines(keepends=True) == color_mapping.format([expected])
306
307 with pytest.raises(
308 ValueError,
309 match=re.escape("indents size (2) should have same size as lines (1)"),
310 ):
311 tw._write_source(["assert 0"], [" ", " "])
312
313
314def test_highlight_empty_source() -> None:

Callers

nothing calls this directly

Calls 3

_write_sourceMethod · 0.95
getvalueMethod · 0.45
formatMethod · 0.45

Tested by

no test coverage detected