Пример #1
0
    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)