11#!/usr/bin/env python3
22"""tests for picnic.py"""
33
4+ from ast import arg
5+ from doctest import OutputChecker
46import os
57from subprocess import getoutput
68
7- prg = ' ./picnic.py'
9+ prg = " ./picnic.py"
810
911
1012# --------------------------------------------------
@@ -18,51 +20,72 @@ def test_exists():
1820def test_usage ():
1921 """usage"""
2022
21- for flag in ['' , '-h' , ' --help' ]:
22- out = getoutput (f' { prg } { flag } ' )
23- assert out .lower ().startswith (' usage' )
23+ for flag in ["" , "-h" , " --help" ]:
24+ out = getoutput (f" { prg } { flag } " )
25+ assert out .lower ().startswith (" usage" )
2426
2527
2628# --------------------------------------------------
2729def test_one ():
2830 """one item"""
2931
30- out = getoutput (f' { prg } chips' )
31- assert out .strip () == ' You are bringing chips.'
32+ out = getoutput (f" { prg } chips" )
33+ assert out .strip () == " You are bringing chips."
3234
3335
3436# --------------------------------------------------
3537def test_two ():
3638 """two items"""
3739
3840 out = getoutput (f'{ prg } soda "french fries"' )
39- assert out .strip () == ' You are bringing soda and french fries.'
41+ assert out .strip () == " You are bringing soda and french fries."
4042
4143
4244# --------------------------------------------------
4345def test_more_than_two ():
4446 """more than two items"""
4547
4648 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.' )
49+ out = getoutput (f"{ prg } { arg } " )
50+ expected = (
51+ "You are bringing potato chips, coleslaw, " "cupcakes, and French silk pie."
52+ )
5053 assert out .strip () == expected
5154
5255
5356# --------------------------------------------------
5457def test_two_sorted ():
5558 """two items sorted output"""
5659
57- out = getoutput (f' { prg } -s soda candy' )
58- assert out .strip () == ' You are bringing candy and soda.'
60+ out = getoutput (f" { prg } -s soda candy" )
61+ assert out .strip () == " You are bringing candy and soda."
5962
6063
6164# --------------------------------------------------
6265def test_more_than_two_sorted ():
6366 """more than two items sorted output"""
6467
65- arg = 'bananas apples dates cherries'
66- out = getoutput (f'{ prg } { arg } --sorted' )
67- expected = ('You are bringing apples, bananas, cherries, and dates.' )
68+ arg = "bananas apples dates cherries"
69+ out = getoutput (f"{ prg } { arg } --sorted" )
70+ expected = "You are bringing apples, bananas, cherries, and dates."
71+ assert out .strip () == expected
72+
73+
74+ # --------------------------------------------------
75+ def test_removal_of_oxford_comma ():
76+ """Oxford comma removed with optional arguement"""
77+
78+ arg = "bananas apples dates cherries"
79+ out = getoutput (f"{ prg } { arg } --no_oxford_comma" )
80+ expected = "You are bringing bananas, apples, dates and cherries."
81+ assert out .strip () == expected
82+
83+
84+ # --------------------------------------------------
85+ def test_alternative_separator ():
86+ """Different separator incorporated"""
87+
88+ arg = "bananas apples dates cherries"
89+ out = getoutput (f"{ prg } { arg } -c _" )
90+ expected = "You are bringing bananas_ apples_ dates_ and cherries."
6891 assert out .strip () == expected
0 commit comments