Exemple #1
0
 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")
Exemple #2
0
 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())
Exemple #3
0
 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")
Exemple #4
0
 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")