Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 2d8bf0e

Browse files
committed
ch03: fix test and reformat
1 parent 6dc5691 commit 2d8bf0e

File tree

1 file changed

+16
-15
lines changed

1 file changed

+16
-15
lines changed

03_picnic/test.py

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import os
55
from subprocess import getoutput
66

7-
prg = './picnic.py'
7+
prg = "picnic.py"
88

99

1010
# --------------------------------------------------
@@ -18,51 +18,52 @@ def test_exists():
1818
def test_usage():
1919
"""usage"""
2020

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"{prg} {flag}")
23+
assert out.lower().startswith("usage")
2424

2525

2626
# --------------------------------------------------
2727
def test_one():
2828
"""one item"""
2929

30-
out = getoutput(f'{prg} chips')
31-
assert out.strip() == 'You are bringing chips.'
30+
out = getoutput(f"{prg} chips")
31+
assert out.strip() == "You are bringing chips."
3232

3333

3434
# --------------------------------------------------
3535
def test_two():
3636
"""two items"""
3737

3838
out = getoutput(f'{prg} soda "french fries"')
39-
assert out.strip() == 'You are bringing soda and french fries.'
39+
assert out.strip() == "You are bringing soda and french fries."
4040

4141

4242
# --------------------------------------------------
4343
def test_more_than_two():
4444
"""more than two items"""
4545

4646
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"{prg} {arg}")
48+
expected = (
49+
"You are bringing potato chips, coleslaw, " "cupcakes, and French silk pie."
50+
)
5051
assert out.strip() == expected
5152

5253

5354
# --------------------------------------------------
5455
def test_two_sorted():
5556
"""two items sorted output"""
5657

57-
out = getoutput(f'{prg} -s soda candy')
58-
assert out.strip() == 'You are bringing candy and soda.'
58+
out = getoutput(f"{prg} -s soda candy")
59+
assert out.strip() == "You are bringing candy and soda."
5960

6061

6162
# --------------------------------------------------
6263
def test_more_than_two_sorted():
6364
"""more than two items sorted output"""
6465

65-
arg = 'bananas apples dates cherries'
66-
out = getoutput(f'{prg} {arg} --sorted')
67-
expected = ('You are bringing apples, bananas, cherries, and dates.')
66+
arg = "bananas apples dates cherries"
67+
out = getoutput(f"{prg} {arg} --sorted")
68+
expected = "You are bringing apples, bananas, cherries, and dates."
6869
assert out.strip() == expected

0 commit comments

Comments
 (0)