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")
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
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
def test_get_pattern(): """ lib/lazyregex.py: Test get_pattern() """ l = LazyRegex("beep") assert l.get_pattern() == "beep"
def test_get_regex(): """ lib/lazyregex.py: Tests LazyRegex.get_regex() method """ l = LazyRegex("beep") assert type(l.get_regex()) == type(re.compile("beep"))
def test_init(): """ lib/lazyregex.py: Test LazyRegex initialization and parameter assignment """ l = LazyRegex("beep") assert l.get_pattern() == "beep"
""" 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.