예제 #1
0
파일: widgets.py 프로젝트: zetdyos/coffe
    def generate_captcha(self):
        # get operator for calculation
        operator = get_operator()

        # get integers for calculation
        x, y = get_numbers(self.start_int, self.end_int, operator)

        # set question to display in output
        self.set_question(x, y, operator)

        # preform the calculation
        total = calculate(x, y, operator)

        return hash_answer(total)
 def test_calculate_raises_on_unknown_op(self):
     with self.assertRaises(KeyError):
         utils.calculate(1, 1, '/')
 def test_calculate_multiplying(self):
     result = utils.calculate(1, 1, '*')
     self.assertEqual(result, 1)
 def test_calculate_subtracting(self):
     result = utils.calculate(1, 1, '-')
     self.assertEqual(result, 0)
 def test_calculate_adding(self):
     result = utils.calculate(1, 1, '+')
     self.assertEqual(result, 2)
예제 #6
0
 def test_calculate_raises_on_unknown_op(self):
     with self.assertRaises(KeyError):
         utils.calculate(1, 1, '/')
예제 #7
0
 def test_calculate_multiplying(self):
     result = utils.calculate(1, 1, '*')
     self.assertEqual(result, 1)
예제 #8
0
 def test_calculate_subtracting(self):
     result = utils.calculate(1, 1, '-')
     self.assertEqual(result, 0)
예제 #9
0
 def test_calculate_adding(self):
     result = utils.calculate(1, 1, '+')
     self.assertEqual(result, 2)