-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_mean.py
More file actions
42 lines (35 loc) · 942 Bytes
/
Copy pathtest_mean.py
File metadata and controls
42 lines (35 loc) · 942 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
31
32
33
34
35
36
37
38
39
40
41
42
from mean import mean
def test_ints():
num_list = [1,2,3,4,5]
obs = mean(num_list)
exp = 3
assert obs == exp
# when there is 0 in the list
def test_zero_in_list():
num_list = [3,4,0,5]
obs = mean(num_list)
exp = 3
assert obs == exp
# when the results is a double
def test_double_as_result():
num_list = [3,4,5]
obs = mean(num_list)
exp = 4
assert exp - 0.0001 < obs < exp + 0.0001
# when the results is a really large number
def test_large_result():
num_list = [3E7,4E7,5E7]
obs = mean(num_list)
exp = 4E7
assert exp - 0.0001E7 < obs < exp + 0.0001E7
# when the elements are doubles\, not integeres
def test_double_as_input():
num_list = [3.0,4.0,5]
obs = mean(num_list)
exp = 4
assert exp - 0.0001 < obs < exp + 0.0001
# test_ints()
# test_zero_in_list()
# test_double_as_result()
# test_large_result()
# test_double_as_input()