-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_playground.py
More file actions
30 lines (20 loc) · 791 Bytes
/
Copy pathtest_playground.py
File metadata and controls
30 lines (20 loc) · 791 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
"""
Run the tests by executing, for all test classes:
$ python -m unittest -v test_playground.py
or
$ python test_playground.py
"""
import math
import unittest
from epsilon import equal_in_practice
from playground import average
class Test_average(unittest.TestCase):
def test_GivenAnEmptyInput_When_average_ThenExceptionIsRaised(self):
self.assertRaises(ValueError, average)
def test_GivenSingleParameterP_When_average_ThenReturnP(self):
self.assertTrue(equal_in_practice(average(1), 1))
self.assertTrue(equal_in_practice(average(math.pi), math.pi))
def test_Given2Parameters_When_average_ThenReturnHalfTheirSum(self):
self.assertTrue(equal_in_practice(average(1, 2), (1+2)/2.))
if __name__ == '__main__':
unittest.main()