def test_find_matching_paren_throws_exception_on_bad_initial_position( self): """If asked to find closing paren from an index where there is no opening paren, the function should raise an error""" with assert_raises(AssertionError): find_matching_paren("string without parens", 4)
def test_find_matching_paren_throws_exception_on_no_closing_paren(self): """The function should raise error when there is no matching paren to be found""" with assert_raises_regexp(SyntaxError, "Unbalanced expression"): find_matching_paren("string (without closing paren", 7)
def test_find_matching_empty_parens(self): assert_equals(1, find_matching_paren("()", 0))
def test_find_matching_paren(self): source = "(foo (bar) '(this ((is)) quoted))" assert_equals(32, find_matching_paren(source, 0)) assert_equals(9, find_matching_paren(source, 5))
def test_find_matching_paren_throws_exception_on_bad_initial_position(self): """If asked to find closing paren from an index where there is no opening paren, the function should raise an error""" with assert_raises(AssertionError): find_matching_paren("string without parens", 4)