def test_matches_throws_exceptions_two_match(self): clm = Matcher() clm.add_handler(ConstTemplate(), lambda a, b: self.const_call(a, b), True) clm.add_handler(ConstTemplate(), lambda a, b: self.const_call(a, b), True) self.assertRaises(Exception, clm.matches, "ASD")
def setUp(self): self.ifed() self.__matcher = Matcher() self.__matcher.startdir = '.' self.__matcher.add_handler( Template(["create", "problem", "#shortname"]), problem_gen.generate_problem, True) self.__matcher.matches("create problem problem_test".split())
def test_matches(self): clm = Matcher() clm.add_handler(NoneTemplate(), lambda: self.return_0(), True) clm.add_handler(ConstTemplate(), lambda a, b: self.const_call(a, b), True) self.assertEqual(clm.matches("ASDASD"), "const_call")
def test_matches_throws_exceptions_no_match(self): clm = Matcher() clm.add_handler(NoneTemplate(), lambda: self.return_0(), True) self.assertRaises(Exception, clm.matches, "ASD") self.assertRaises(Exception, clm.matches, "QWE")