(has_markup, code_highlight, expected, color_mapping)
| 278 | ], |
| 279 | ) |
| 280 | def 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"], [" ", " "]) |
nothing calls this directly
no test coverage detected