-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpython-named-tuples.py
More file actions
81 lines (57 loc) · 1.8 KB
/
python-named-tuples.py
File metadata and controls
81 lines (57 loc) · 1.8 KB
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
from collections import namedtuple
from textwrap import dedent
Student = namedtuple('Student', 'ID, MARKS, NAME, CLASS' )
def parse_input(lines):
""" WIP """
Student = namedtuple('Student', lines[0])
student1 = Student(lines[1])
return student1
def get_average(*args):
""" WIP"""
pass
# def test_parse_empty():
# lines = "i,t".splitlines()
#
# assert parse_input(lines) == 'Student("ID=1, MARKS=97, NAME=Raymond, CLASS=7")'
# def test_parse_empty():
# lines = dedent("""\
# ID, MARKS, NAME, CLASS
# , , ,
# """).splitlines()
#
# assert parse_input(lines) == 'Student("ID=1, MARKS=97, NAME=Raymond, CLASS=7")'
def test_parse_one_line():
lines = dedent("""\
ID, MARKS, NAME, CLASS
1, 97, Raymond, 7
""").splitlines()
assert parse_input(lines) == 'Student("ID=1, MARKS=97, NAME=Raymond, CLASS=7")'
def test_parse():
lines = dedent("""\
ID, MARKS, NAME, CLASS
1, 97, Raymond, 7
2, 50, Steven, 4
3, 91, Adrian, 9
4, 72, Stewart, 5
5, 80, Peter, 6
""").splitlines()
# dedent("""\
# Lions 3, Snakes 3 Lions 3, Snakes 3
# Tarantulas 1, FC Awesome 0 Tarantulas 1, FC Awesome 0
# Lions 1, FC Awesome 1 Lions 1, FC Awesome 1
# Tarantulas 3, Snakes 1 Tarantulas 3, Snakes 1
# Lions 4, Grouches 0 Lions 4, Grouches 0
# """)
# """).splitlines()
assert parse_input(lines) == False
def test_average():
"""
5
ID MARKS NAME CLASS
1 97 Raymond 7
2 50 Steven 4
3 91 Adrian 9
4 72 Stewart 5
5 80 Peter 6
"""
assert get_average("a","b","c") == ("a","b","c")