forked from HasBob/IntroPython2015
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_lambda.py
More file actions
49 lines (31 loc) · 976 Bytes
/
test_lambda.py
File metadata and controls
49 lines (31 loc) · 976 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
43
44
45
46
47
48
49
"""
some simple tests for the function builder
designed to run with py.test or nose.
"""
from lambda_keyword import function_builder
# uncomment to test second version
# from lambda_keyword import function_builder2 as function_builder
def test_length():
"""
the function should return a list of the length input
"""
assert len(function_builder(0)) == 0
assert len(function_builder(3)) == 3
assert len(function_builder(5)) == 5
def test_increment():
"""
the functions in the list should increment the input values
"""
func_list = function_builder(5)
assert func_list[0](3) == 3
assert func_list[1](3) == 4
assert func_list[2](3) == 5
assert func_list[3](3) == 6
def test_increment2():
"""
the functions in the list should increment the input values
"""
func_list = function_builder(10)
assert func_list[0](12) == 12
assert func_list[1](10) == 11
assert func_list[9](3) == 12