|
4 | 4 | import os
|
5 | 5 | from subprocess import getoutput
|
6 | 6 |
|
7 |
| -prg = './picnic.py' |
| 7 | +PRG = "./picnic.py" |
8 | 8 |
|
9 | 9 |
|
10 | 10 | # --------------------------------------------------
|
11 | 11 | def test_exists():
|
12 | 12 | """exists"""
|
13 | 13 |
|
14 |
| - assert os.path.isfile(prg) |
| 14 | + assert os.path.isfile(PRG) |
15 | 15 |
|
16 | 16 |
|
17 | 17 | # --------------------------------------------------
|
18 | 18 | def test_usage():
|
19 | 19 | """usage"""
|
20 | 20 |
|
21 |
| - for flag in ['', '-h', '--help']: |
22 |
| - out = getoutput(f'{prg} {flag}') |
23 |
| - assert out.lower().startswith('usage') |
| 21 | + for flag in ["", "-h", "--help"]: |
| 22 | + out = getoutput(f"python3 {PRG} {flag}") |
| 23 | + assert out.lower().startswith("usage") |
24 | 24 |
|
25 | 25 |
|
26 | 26 | # --------------------------------------------------
|
27 | 27 | def test_one():
|
28 | 28 | """one item"""
|
29 | 29 |
|
30 |
| - out = getoutput(f'{prg} chips') |
31 |
| - assert out.strip() == 'You are bringing chips.' |
| 30 | + out = getoutput(f"python3 {PRG} chips") |
| 31 | + assert out.strip() == "You are bringing chips." |
32 | 32 |
|
33 | 33 |
|
34 | 34 | # --------------------------------------------------
|
35 | 35 | def test_two():
|
36 | 36 | """two items"""
|
37 | 37 |
|
38 |
| - out = getoutput(f'{prg} soda "french fries"') |
39 |
| - assert out.strip() == 'You are bringing soda and french fries.' |
| 38 | + out = getoutput(f'python3 {PRG} soda "french fries"') |
| 39 | + assert out.strip() == "You are bringing soda and french fries." |
40 | 40 |
|
41 | 41 |
|
42 | 42 | # --------------------------------------------------
|
43 | 43 | def test_more_than_two():
|
44 | 44 | """more than two items"""
|
45 | 45 |
|
46 | 46 | arg = '"potato chips" coleslaw cupcakes "French silk pie"'
|
47 |
| - out = getoutput(f'{prg} {arg}') |
48 |
| - expected = ('You are bringing potato chips, coleslaw, ' |
49 |
| - 'cupcakes, and French silk pie.') |
| 47 | + out = getoutput(f"python3 {PRG} {arg}") |
| 48 | + expected = "You are bringing potato chips, coleslaw, cupcakes, and French silk pie." |
50 | 49 | assert out.strip() == expected
|
51 | 50 |
|
52 | 51 |
|
53 | 52 | # --------------------------------------------------
|
54 | 53 | def test_two_sorted():
|
55 | 54 | """two items sorted output"""
|
56 | 55 |
|
57 |
| - out = getoutput(f'{prg} -s soda candy') |
58 |
| - assert out.strip() == 'You are bringing candy and soda.' |
| 56 | + out = getoutput(f"python3 {PRG} -s soda candy") |
| 57 | + assert out.strip() == "You are bringing candy and soda." |
59 | 58 |
|
60 | 59 |
|
61 | 60 | # --------------------------------------------------
|
62 | 61 | def test_more_than_two_sorted():
|
63 | 62 | """more than two items sorted output"""
|
64 | 63 |
|
65 |
| - arg = 'bananas apples dates cherries' |
66 |
| - out = getoutput(f'{prg} {arg} --sorted') |
67 |
| - expected = ('You are bringing apples, bananas, cherries, and dates.') |
| 64 | + arg = "bananas apples dates cherries" |
| 65 | + out = getoutput(f"python3 {PRG} {arg} --sorted") |
| 66 | + expected = "You are bringing apples, bananas, cherries, and dates." |
68 | 67 | assert out.strip() == expected
|
0 commit comments