(has_markup, code_highlight, expected, color_mapping)
| 296 | ], |
| 297 | ) |
| 298 | def 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 | |
| 314 | def test_highlight_empty_source() -> None: |
nothing calls this directly
no test coverage detected