Initial import to Tizen
[profile/ivi/python-twisted.git] / doc / core / howto / listings / trial / calculus / test / test_base_2b.py
1 from calculus.base_2 import Calculation
2 from twisted.trial import unittest
3
4
5
6 class CalculationTestCase(unittest.TestCase):
7     def setUp(self):
8         self.calc = Calculation()
9
10
11     def _test(self, operation, a, b, expected):
12         result = operation(a, b)
13         self.assertEqual(result, expected)
14
15
16     def test_add(self):
17         self._test(self.calc.add, 3, 8, 11)
18
19
20     def test_subtract(self):
21         self._test(self.calc.subtract, 7, 3, 4)
22
23
24     def test_multiply(self):
25         self._test(self.calc.multiply, 6, 9, 54)
26
27
28     def test_divide(self):
29         self._test(self.calc.divide, 12, 5, 2)