def test_wrong_position_for_opening_brace_raises(self): with self.assertRaises(ValueError): typesetting.get_matching_brace("moo", 1)
def test_that_unmatched_braces_raise_exception(self): with self.assertRaises(ValueError): typesetting.get_matching_brace("text{foooooooo", 4) with self.assertRaises(ValueError): typesetting.get_matching_brace('text{jo"{o....}', 4)
def test_outer_brace_found(self): text = 'text{o, bla\\"{o}dfdx.}ds' self.assertEqual(typesetting.get_matching_brace(text, 4), len(text) - 3)
def test_inner_brace_is_matched(self): text = 'text{o, bla\\"{o}dfdx.}ds' self.assertEqual(typesetting.get_matching_brace(text, 13), 15)
def test_closing_brace_found_when_only_one_brace_present(self): text = "text{ok}" self.assertEqual(typesetting.get_matching_brace(text, 4), len(text) - 1) self.assertEqual(typesetting.get_matching_brace(text + "foo", 4), len(text) - 1)