forked from kyclark/tiny_python_projects
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.py
More file actions
executable file
·68 lines (45 loc) · 1.7 KB
/
test.py
File metadata and controls
executable file
·68 lines (45 loc) · 1.7 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
#!/usr/bin/env python3
"""tests for picnic.py"""
import os
from subprocess import getoutput
prg = './picnic.py'
# --------------------------------------------------
def test_exists():
"""exists"""
assert os.path.isfile(prg)
# --------------------------------------------------
def test_usage():
"""usage"""
for flag in ['', '-h', '--help']:
out = getoutput(f'{prg} {flag}')
assert out.lower().startswith('usage')
# --------------------------------------------------
def test_one():
"""one item"""
out = getoutput(f'{prg} chips')
assert out.strip() == 'You are bringing chips.'
# --------------------------------------------------
def test_two():
"""two items"""
out = getoutput(f'{prg} soda "french fries"')
assert out.strip() == 'You are bringing soda and french fries.'
# --------------------------------------------------
def test_more_than_two():
"""more than two items"""
arg = '"potato chips" coleslaw cupcakes "French silk pie"'
out = getoutput(f'{prg} {arg}')
expected = ('You are bringing potato chips, coleslaw, '
'cupcakes, and French silk pie.')
assert out.strip() == expected
# --------------------------------------------------
def test_two_sorted():
"""two items sorted output"""
out = getoutput(f'{prg} -s soda candy')
assert out.strip() == 'You are bringing candy and soda.'
# --------------------------------------------------
def test_more_than_two_sorted():
"""more than two items sorted output"""
arg = 'bananas apples dates cherries'
out = getoutput(f'{prg} {arg} --sorted')
expected = ('You are bringing apples, bananas, cherries, and dates.')
assert out.strip() == expected