Exemplo n.º 1
0
def test_match():
    """
    lib/lazyregex.py: Test the LazyRegex.match() method
    """
    l = LazyRegex("beep")
    assert l.match("This shouldn't match! beep beep beep.") is None
    assert l.match("beep this should match")
Exemplo n.º 2
0
def test_match():
    """
    lib/lazyregex.py: Test the LazyRegex.match() method
    """
    l = LazyRegex("beep")
    assert l.match("This shouldn't match! beep beep beep.") is None
    assert l.match("beep this should match")
Exemplo n.º 3
0
def test_search():
    """
    lib/lazyregex.py: Test the LazyRegex.search() method
    """
    l = LazyRegex("beep")
    assert l.search("This is a beep sentence.")
    assert l.search("This string should not match.") is None
Exemplo n.º 4
0
def test_search():
    """
    lib/lazyregex.py: Test the LazyRegex.search() method
    """
    l = LazyRegex("beep")
    assert l.search("This is a beep sentence.")
    assert l.search("This string should not match.") is None
Exemplo n.º 5
0
def test_laziness():
    """
    lib/lazyregex.py: Test laziness

    Test to make sure LazyRegex doesn't create the compiled regular
    expression object until it is needed.
    """
    l = LazyRegex("beep")
    assert l._regex is None
    assert l.get_regex()
    assert l._regex is not None
Exemplo n.º 6
0
def test_laziness():
    """
    lib/lazyregex.py: Test laziness

    Test to make sure LazyRegex doesn't create the compiled regular
    expression object until it is needed.
    """
    l = LazyRegex("beep")
    assert l._regex is None
    assert l.get_regex()
    assert l._regex is not None
Exemplo n.º 7
0
def test_get_pattern():
    """
    lib/lazyregex.py: Test get_pattern()
    """
    l = LazyRegex("beep")
    assert l.get_pattern() == "beep"
Exemplo n.º 8
0
def test_get_regex():
    """
    lib/lazyregex.py: Tests LazyRegex.get_regex() method
    """
    l = LazyRegex("beep")
    assert type(l.get_regex()) == type(re.compile("beep"))
Exemplo n.º 9
0
def test_init():
    """
    lib/lazyregex.py: Test LazyRegex initialization and parameter assignment
    """
    l = LazyRegex("beep")
    assert l.get_pattern() == "beep"
Exemplo n.º 10
0
"""
File for GitHub markdown switches
"""
from anchorhub.lib.armedcheckswitch import ArmedCheckSwitch
from anchorhub.lib.lazyregex import LazyRegex
import anchorhub.builtin.regex.markdown as mdrx

# LazyRegex objects for testing if a line indicates the start of a code block
# Or the end of a code block
code_start = LazyRegex(mdrx.code_block_start)
code_end = LazyRegex(mdrx.code_block_end)


def code_block_start_test(lines, index):
    """
    Tests to see if the line at the current index of lines indicates the
    start of a Markdown code block.

    :param lines: List of strings, with each entry corresponding to a single
        line in a text file
    :param index: The current line in lines
    :return: True if the current line indicates the start of a code block
    """
    return code_start.match(lines[index])


def code_block_end_test(lines, index):
    """
    Tests to see if the line at the current index of lines indicates the
    end of a Markdown code block.
Exemplo n.º 11
0
def test_get_pattern():
    """
    lib/lazyregex.py: Test get_pattern()
    """
    l = LazyRegex("beep")
    assert l.get_pattern() == "beep"
Exemplo n.º 12
0
def test_get_regex():
    """
    lib/lazyregex.py: Tests LazyRegex.get_regex() method
    """
    l = LazyRegex("beep")
    assert type(l.get_regex()) == type(re.compile("beep"))
Exemplo n.º 13
0
def test_init():
    """
    lib/lazyregex.py: Test LazyRegex initialization and parameter assignment
    """
    l = LazyRegex("beep")
    assert l.get_pattern() == "beep"