diff --git a/testing/code/test_terminal_writer.py b/testing/code/test_terminal_writer.py deleted file mode 100644 index 01da3c235..000000000 --- a/testing/code/test_terminal_writer.py +++ /dev/null @@ -1,28 +0,0 @@ -import re -from io import StringIO - -import pytest -from _pytest._io import TerminalWriter - - -@pytest.mark.parametrize( - "has_markup, expected", - [ - pytest.param( - True, "{kw}assert{hl-reset} {number}0{hl-reset}\n", id="with markup" - ), - pytest.param(False, "assert 0\n", id="no markup"), - ], -) -def test_code_highlight(has_markup, expected, color_mapping): - f = StringIO() - tw = TerminalWriter(f) - tw.hasmarkup = has_markup - tw._write_source(["assert 0"]) - assert f.getvalue().splitlines(keepends=True) == color_mapping.format([expected]) - - with pytest.raises( - ValueError, - match=re.escape("indents size (2) should have same size as lines (1)"), - ): - tw._write_source(["assert 0"], [" ", " "]) diff --git a/testing/io/test_terminalwriter.py b/testing/io/test_terminalwriter.py index 1e4f04ac0..b3bd9cfae 100644 --- a/testing/io/test_terminalwriter.py +++ b/testing/io/test_terminalwriter.py @@ -1,5 +1,6 @@ import io import os +import re import shutil import sys from typing import Generator @@ -207,3 +208,26 @@ class TestTerminalWriterLineWidth: assert len(text) == 10 tw.write(text) assert tw.width_of_current_line == 9 + + +@pytest.mark.parametrize( + "has_markup, expected", + [ + pytest.param( + True, "{kw}assert{hl-reset} {number}0{hl-reset}\n", id="with markup" + ), + pytest.param(False, "assert 0\n", id="no markup"), + ], +) +def test_code_highlight(has_markup, expected, color_mapping): + f = io.StringIO() + tw = terminalwriter.TerminalWriter(f) + tw.hasmarkup = has_markup + tw._write_source(["assert 0"]) + assert f.getvalue().splitlines(keepends=True) == color_mapping.format([expected]) + + with pytest.raises( + ValueError, + match=re.escape("indents size (2) should have same size as lines (1)"), + ): + tw._write_source(["assert 0"], [" ", " "])