Пример #1
0
 def test_additional_checker_used(self):
     params = {
         ex.OPTIONS: ["echoprog.py"],
         ex.INPUT: "42",
         ex.EXIT_CODE: 0,
         ex.STDOUT: "41",
         ex.CHECKERS: [DoubleChecker(abs_tolerance=1.1)]
     }
     #canary:
     res, mes = execute("python", params)
     self.assertEqual(res, True)
     #test:
     params[ex.CHECKERS] = [DoubleChecker(abs_tolerance=1.1)]
     params[ex.ADDITIONAL_CHECKERS] = [DefaultChecker()]
     res, mes = execute("python", params)
     self.assertEqual(res, False)
Пример #2
0
 def test_rel_tolerance_not_ok(self):
     params = {
         ex.OPTIONS: ["echoprog.py"],
         ex.INPUT: "0.1",
         ex.EXIT_CODE: 0,
         ex.STDOUT: .081,
         ex.CHECKERS: [DoubleChecker(rel_tolerance=0.1)]
     }
     res, mes = execute("python", params)
     self.assertEqual(res, False)
Пример #3
0
 def test_abs_tolerance_ok(self):
     params = {
         ex.OPTIONS: ["echoprog.py"],
         ex.INPUT: "1.0",
         ex.EXIT_CODE: 0,
         ex.STDOUT: .91,
         ex.CHECKERS: [DoubleChecker(abs_tolerance=0.1)]
     }
     res, mes = execute("python", params)
     self.assertEqual(res, True)
     self.assertEqual(mes, "")
Пример #4
0
 def test_expected_output_not_double(self):
     params = {
         ex.OPTIONS: ["echoprog.py"],
         ex.INPUT: "1.0",
         ex.EXIT_CODE: 0,
         ex.STDOUT: "1a.0",
         ex.CHECKERS: [DoubleChecker(abs_tolerance=0.9)]
     }
     res, mes = execute("python", params)
     self.assertEqual(res, False)
     self.assertEqual(mes, "Expected value [1a.0] isn't a float value")
Пример #5
0
 def test_checker_overwritten(self):
     params = {
         ex.OPTIONS: ["echoprog.py"],
         ex.INPUT: "42",
         ex.EXIT_CODE: 0,
         ex.STDOUT: "41"
     }
     #canary:
     res, mes = execute("python", params)
     self.assertEqual(res, False)
     #test:
     params[ex.CHECKERS] = [DoubleChecker(abs_tolerance=1.1)]
     res, mes = execute("python", params)
     self.assertEqual(mes, "")
     self.assertEqual(res, True)
Пример #6
0
class TutorialTester:
    exe="python"
    default_parameters = {ex.OPTIONS: ["echoprog.py"],
                          ex.EXIT_CODE: 42,                   
                          ex.INPUT: ""}

    casedata_no_input={}

    casedata_no_input2={ex.STDERR: "", 
                        ex.STDOUT: ""}


    casedata_real_input={ ex.EXIT_CODE: 0, 
                     ex.STDERR: "my_inputmy_input\n", 
                     ex.STDOUT: "my_input\n",  
                     ex.INPUT: "my_input"}

    casedata_double_checker={ ex.EXIT_CODE: 0, 
                              ex.INPUT: "1.0", 
                              ex.STDOUT: ".9", 
                              ex.CHECKERS: [DoubleChecker(rel_tolerance=.1, abs_tolerance=.1)]}

    casedata_add_lambda={ ex.EXIT_CODE: 0, 
                              ex.INPUT: "1.0", 
                              ex.STDOUT: "1.0\n", 
                              ex.ADDITIONAL_CHECKERS: [lambda expected, received: (True,"") if ex.__version__>=(0,2,0) else (False,"exetest is too old")]}
 
    casedata_add_checker={ ex.EXIT_CODE: 0, 
                              ex.INPUT: "1.0", 
                              ex.STDOUT: "1.0\n", 
                              ex.ADDITIONAL_CHECKERS: [VersionChecker((0,2,0))]}

    casedata_overwrite_checker={ ex.EXIT_CODE: 0, 
                              ex.INPUT: "1.0", 
                              ex.STDOUT: "1.0\n", 
                              ex.CHECKERS: [DefaultChecker(), VersionChecker((0,2,0))]}


    casedata_preparers={ ex.EXIT_CODE: 0, 
                              ex.INPUT: "1.0", 
                              ex.STDOUT: "1.0\n", 
                              ex.PREPARERS: [lambda pars : None , lambda pars : ""]}


    casedata_cleaners={ ex.EXIT_CODE: 0, 
                              ex.INPUT: "1.0", 
                              ex.STDOUT: "1.0\n", 
                              ex.CLEANERS: [lambda pars, rec : None , lambda pars, rec : ""]}
Пример #7
0
 def test_checker_used_first(self):
     double_checker = DoubleChecker(abs_tolerance=0.9)
     params = {
         ex.OPTIONS: ["echoprog.py"],
         ex.INPUT: "42",
         ex.EXIT_CODE: 0,
         ex.STDOUT: "41",
         ex.CHECKERS: [double_checker]
     }
     expected_err_msg = "Wrong stdout output! Expected: [41] but received [42\n]"  #default checker message
     #canary:
     res, msg = execute("python", params)
     self.assertEqual(res, False)
     self.assertFalse(msg == expected_err_msg)
     #test:
     params[ex.CHECKERS] = [DefaultChecker()]
     params[ex.ADDITIONAL_CHECKERS] = [double_checker]
     res, msg = execute("python", params)
     self.assertEqual(res, False)
     self.assertEqual(msg, expected_err_msg)