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

Function test_code_highlight

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

Source from the content-addressed store, hash-verified

278 ],
279)
280def test_code_highlight(has_markup, code_highlight, expected, color_mapping):
281 f = io.StringIO()
282 tw = terminalwriter.TerminalWriter(f)
283 tw.hasmarkup = has_markup
284 tw.code_highlight = code_highlight
285 tw._write_source(["assert 0"])
286
287 assert f.getvalue().splitlines(keepends=True) == color_mapping.format([expected])
288
289 with pytest.raises(
290 ValueError,
291 match=re.escape("indents size (2) should have same size as lines (1)"),
292 ):
293 tw._write_source(["assert 0"], [" ", " "])

Callers

nothing calls this directly

Calls 3

_write_sourceMethod · 0.95
getvalueMethod · 0.45
formatMethod · 0.45

Tested by

no test coverage detected