def test_line_validation(): line_to_test = Line("hello", category=" ") with pytest.raises(TypeError): line_to_test.build_line_count(0, False) Line("hello", category=None).build_line_count(0)
get_padding, ) def test_line_validation(): line_to_test = Line("hello", category=" ") with pytest.raises(TypeError): line_to_test.build_line_count(0, False) Line("hello", category=None).build_line_count(0) @pytest.mark.parametrize( "input, padding, want", [ pytest.param( Line(content="", category=LineCategory.data, pre_index=300), 3, "\x1b[37m\x1b[22m\x1b[2m300\x1b[0m | ", id="file: padding==index", ), pytest.param( Line(content="", category=LineCategory.data, pre_index=299), 5, "\x1b[37m\x1b[22m\x1b[2m 299\x1b[0m | ", id="file: padding!=index", ), pytest.param( Line(content="", category=LineCategory.addition, post_index=297,), 3, "\x1b[37m\x1b[22m\x1b[2m \x1b[0m \x1b[37m\x1b[22m\x1b[2m297\x1b[0m | ", id="addition",
format_line_count_break, no_leak_message, ) from ggshield.output.text.text_output import get_offset, get_padding from ggshield.text_utils import Line def test_message_no_secret(snapshot): msg = no_leak_message() snapshot.assert_match(msg) @pytest.mark.parametrize( "lines, want", [ pytest.param([Line(content="", pre_index=4000, post_index=30)], 4, id="padding-pre_index"), pytest.param([Line(content="", pre_index=40, post_index=300)], 3, id="padding-post_index"), pytest.param([Line(content="", pre_index=4000)], 4, id="padding-pre_index-none"), pytest.param([Line(content="", post_index=300)], 3, id="padding-none-post_index"), ], ) def test_get_padding(lines: List[Line], want: int) -> None: assert get_padding(lines) == want
@pytest.mark.parametrize( "matches,lines,is_patch,expected_matches", [ pytest.param( [ Match( "368ac3edf9e850d1c0ff9d6c526496f8237ddf91", "GitHub Token", index_start=22, index_end=62, ) ], [ Line(pre_index=1, content="GutHub:", category=LineCategory.data), Line( pre_index=2, content= "github_token: 368ac3edf9e850d1c0ff9d6c526496f8237ddf91", category=LineCategory.data, ), Line(pre_index=3, content="", category=LineCategory.data), ], False, [ Match( "368ac3edf9e850d1c0ff9d6c526496f8237ddf91", "GitHub Token", line_start=1,
from ggshield.text_utils import Line, LineCategory def test_line_validation(): line_to_test = Line("hello", category=" ") # type: ignore with pytest.raises(TypeError): line_to_test.build_line_count(0, False) Line("hello", category=None).build_line_count(0) @pytest.mark.parametrize( "input, padding, want", [ pytest.param( Line(content="", category=LineCategory.data, pre_index=300), 3, "\x1b[37m\x1b[22m\x1b[2m300\x1b[0m | ", id="file: padding==index", ), pytest.param( Line(content="", category=LineCategory.data, pre_index=299), 5, "\x1b[37m\x1b[22m\x1b[2m 299\x1b[0m | ", id="file: padding!=index", ), pytest.param( Line(content="", category=LineCategory.addition, post_index=297), 3, "\x1b[37m\x1b[22m\x1b[2m \x1b[0m \x1b[37m\x1b[22m\x1b[2m297\x1b[0m | ", id="addition",