Exemple #1
0
def test_context_supplied_as_an_int():
    matches = Matches(
        """A
    B
    C
    D
    A
    B
    C
    D""",
        context=2,
        pattern="A",
        number_lines=True,
    )

    assert set(matches.matching_lines()) == {0, 1, 2, 3, 4, 5, 6}
Exemple #2
0
def test_after():
    matches = Matches(
        """A
B
C
D
A
B
C
D""",
        Context(after=1),
        "A",
        number_lines=True,
    )

    assert set(matches.matching_lines()) == {0, 1, 4, 5}
Exemple #3
0
def test_context():
    matches = Matches(
        """A
    B
    C
    D
    A
    B
    C
    D""",
        Context(context=2),
        "A",
        number_lines=True,
    )

    assert set(matches.matching_lines()) == {0, 1, 2, 3, 4, 5, 6}
Exemple #4
0
def test_before():
    matches = Matches(
        """A
B
C
D
A
B
C
D""",
        Context(before=1),
        "A",
        number_lines=True,
    )

    assert set(matches.matching_lines()) == {0, 4, 3}