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

Skip to content

Commit c04e176

Browse files
committed
cleanup
1 parent 2e94f78 commit c04e176

File tree

9 files changed

+30
-33
lines changed

9 files changed

+30
-33
lines changed

03_picnic/test.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ def test_usage():
1919
"""usage"""
2020

2121
for flag in ['', '-h', '--help']:
22-
out = getoutput('{} {}'.format(prg, flag))
22+
out = getoutput(f'{prg} {flag}')
2323
assert out.lower().startswith('usage')
2424

2525

@@ -49,13 +49,15 @@ def test_more_than_two():
4949
'cupcakes, and French silk pie.')
5050
assert out.strip() == expected
5151

52+
5253
# --------------------------------------------------
5354
def test_two_sorted():
5455
"""two items sorted output"""
5556

5657
out = getoutput(f'{prg} -s soda candy')
5758
assert out.strip() == 'You are bringing candy and soda.'
5859

60+
5961
# --------------------------------------------------
6062
def test_more_than_two_sorted():
6163
"""more than two items sorted output"""

04_jump_the_five/test.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ def test_usage():
1919
"""usage"""
2020

2121
for flag in ['-h', '--help']:
22-
rv, out = getstatusoutput('{} {}'.format(prg, flag))
22+
rv, out = getstatusoutput(f'{prg} {flag}')
2323
assert rv == 0
2424
assert out.lower().startswith('usage')
2525

@@ -28,7 +28,7 @@ def test_usage():
2828
def test_01():
2929
"""test"""
3030

31-
rv, out = getstatusoutput('{} 123-456-7890'.format(prg))
31+
rv, out = getstatusoutput(f'{prg} 123-456-7890')
3232
assert rv == 0
3333
assert out == '987-604-3215'
3434

@@ -37,7 +37,6 @@ def test_01():
3737
def test_02():
3838
"""test"""
3939

40-
rv, out = getstatusoutput(
41-
'{} "That number to call is 098-765-4321."'.format(prg))
40+
rv, out = getstatusoutput(f'{prg} "That number to call is 098-765-4321."')
4241
assert rv == 0
4342
assert out.rstrip() == 'That number to call is 512-340-6789.'

09_abuse/test.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ def test_usage():
2222
"""usage"""
2323

2424
for flag in ['-h', '--help']:
25-
rv, out = getstatusoutput('{} {}'.format(prg, flag))
25+
rv, out = getstatusoutput(f'{prg} {flag}')
2626
assert rv == 0
2727
assert re.match("usage", out, re.IGNORECASE)
2828

10_telephone/test.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ def test_usage():
2424
"""usage"""
2525

2626
for flag in ['', '-h', '--help']:
27-
out = getoutput('{} {}'.format(prg, flag))
27+
out = getoutput(f'{prg} {flag}')
2828
assert re.match('usage', out, re.IGNORECASE)
2929

3030

@@ -55,8 +55,7 @@ def test_bad_mutation():
5555
for val in ['-1.0', '10.0']:
5656
rv, out = getstatusoutput(f'{prg} -m {val} {fox}')
5757
assert rv > 0
58-
assert re.search(
59-
'--mutations "{}" must be between 0 and 1'.format(val), out)
58+
assert re.search(f'--mutations "{val}" must be between 0 and 1', out)
6059

6160

6261
# --------------------------------------------------

11_bottles_of_beer/test.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ def test_usage():
2222
"""usage"""
2323

2424
for flag in ['-h', '--help']:
25-
rv, out = getstatusoutput('{} {}'.format(prg, flag))
25+
rv, out = getstatusoutput(f'{prg} {flag}')
2626
assert rv == 0
2727
assert re.match("usage", out, re.IGNORECASE)
2828

@@ -31,7 +31,7 @@ def test_usage():
3131
def test_bad_int():
3232
"""Bad integer value"""
3333

34-
rv, out = getstatusoutput('{} -n -1'.format(prg))
34+
rv, out = getstatusoutput(f'{prg} -n -1')
3535
assert rv != 0
3636
assert re.search(r'--num \(-1\) must > 0', out)
3737

@@ -40,7 +40,7 @@ def test_bad_int():
4040
def test_float():
4141
"""float value"""
4242

43-
rv, out = getstatusoutput('{} --num 2.1'.format(prg))
43+
rv, out = getstatusoutput(f'{prg} --num 2.1')
4444
assert rv != 0
4545
assert re.search(r"invalid int value: '2.1'", out)
4646

@@ -49,7 +49,7 @@ def test_float():
4949
def test_str():
5050
"""str value"""
5151

52-
rv, out = getstatusoutput('{} -n lsdfkl'.format(prg))
52+
rv, out = getstatusoutput(f'{prg} -n lsdfkl')
5353
assert rv != 0
5454
assert re.search(r"invalid int value: 'lsdfkl'", out)
5555

@@ -63,7 +63,7 @@ def test_one():
6363
'Take one down, pass it around,\n'
6464
'No more bottles of beer on the wall!')
6565

66-
rv, out = getstatusoutput('{} --num 1'.format(prg))
66+
rv, out = getstatusoutput(f'{prg} --num 1')
6767
assert rv == 0
6868
assert out == expected
6969

@@ -81,7 +81,7 @@ def test_two():
8181
'Take one down, pass it around,\n'
8282
'No more bottles of beer on the wall!')
8383

84-
rv, out = getstatusoutput('{} -n 2'.format(prg))
84+
rv, out = getstatusoutput(f'{prg} -n 2')
8585
assert rv == 0
8686
assert out == expected
8787

@@ -96,7 +96,7 @@ def test_random():
9696

9797
for n in random.choices(list(sums.keys()), k=10):
9898
flag = '-n' if random.choice([0, 1]) == 1 else '--num'
99-
rv, out = getstatusoutput('{} {} {}'.format(prg, flag, n))
99+
rv, out = getstatusoutput(f'{prg} {flag} {n}')
100100
out += '\n' # because the last newline is removed
101101
assert rv == 0
102102
assert hashlib.md5(out.encode('utf-8')).hexdigest() == sums[n]

12_ransom/test.py

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ def test_usage():
2828
"""usage"""
2929

3030
for flag in ['-h', '--help']:
31-
rv, out = getstatusoutput('{} {}'.format(prg, flag))
31+
rv, out = getstatusoutput(f'{prg} {flag}')
3232
assert rv == 0
3333
assert re.match("usage", out, re.IGNORECASE)
3434

@@ -40,10 +40,10 @@ def test_text1():
4040
('3', 'thE quICk BROwn Fox jUmPS OVEr the lAZY DOG.')]
4141

4242
for seed, expected in tests:
43-
cmd = '{} {} {} "{}"'.format(prg, seed_flag(), seed, in_text)
44-
rv, out = getstatusoutput(cmd)
43+
rv, out = getstatusoutput(f'{prg} {seed_flag()} {seed} "{in_text}"')
4544
assert out.strip() == expected
4645

46+
4747
# --------------------------------------------------
4848
def test_text2():
4949
in_text = 'Now is the time for all good men to come to the aid of the party.'
@@ -55,8 +55,7 @@ def test_text2():
5555
]
5656

5757
for seed, expected in tests:
58-
cmd = '{} {} {} "{}"'.format(prg, seed_flag(), seed, in_text)
59-
rv, out = getstatusoutput(cmd)
58+
rv, out = getstatusoutput(f'{prg} {seed_flag()} {seed} "{in_text}"')
6059
assert out.strip() == expected
6160

6261

@@ -66,8 +65,7 @@ def test_file1():
6665
('3', 'thE quICk BROwn Fox jUmPS OVEr the lAZY DOG.')]
6766

6867
for seed, expected in tests:
69-
cmd = '{} {} {} {}'.format(prg, seed_flag(), seed, fox)
70-
rv, out = getstatusoutput(cmd)
68+
rv, out = getstatusoutput(f'{prg} {seed_flag()} {seed} {fox}')
7169
assert out.strip() == expected
7270

7371

@@ -81,6 +79,5 @@ def test_file2():
8179
]
8280

8381
for seed, expected in tests:
84-
cmd = '{} {} {} {}'.format(prg, seed_flag(), seed, now)
85-
rv, out = getstatusoutput(cmd)
82+
rv, out = getstatusoutput(f'{prg} {seed_flag()} {seed} {now}')
8683
assert out.strip() == expected

13_twelve_days/test.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ def test_usage():
3333
"""usage"""
3434

3535
for flag in ['-h', '--help']:
36-
rv, out = getstatusoutput('{} {}'.format(prg, flag))
36+
rv, out = getstatusoutput(f'{prg} {flag}')
3737
assert rv == 0
3838
assert re.match("usage", out, re.IGNORECASE)
3939

@@ -43,7 +43,7 @@ def test_bad_num():
4343
"""test bad_num"""
4444

4545
for n in [random.choice(r) for r in (range(-10, -1), range(13, 20))]:
46-
rv, out = getstatusoutput('{} -n {}'.format(prg, n))
46+
rv, out = getstatusoutput(f'{prg} -n {n}')
4747
assert rv != 0
4848
assert re.search(f'--num "{n}" must be between 1 and 12', out)
4949

17_mad_libs/test.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ def test_usage():
2626
"""usage"""
2727

2828
for flag in ['-h', '--help']:
29-
rv, out = getstatusoutput('{} {}'.format(prg, flag))
29+
rv, out = getstatusoutput(f'{prg} {flag}')
3030
assert rv == 0
3131
assert out.lower().startswith('usage')
3232

18_gematria/test.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ def test_usage():
2323
"""usage"""
2424

2525
for flag in ['-h', '--help']:
26-
rv, out = getstatusoutput('{} {}'.format(prg, flag))
26+
rv, out = getstatusoutput(f'{prg} {flag}')
2727
assert rv == 0
2828
assert re.match("usage", out, re.IGNORECASE)
2929

@@ -32,31 +32,31 @@ def test_usage():
3232
def test_text():
3333
"""Text"""
3434

35-
out = getoutput('{} "foo bar baz"'.format(prg))
35+
out = getoutput(f'{prg} "foo bar baz"')
3636
assert out.strip() == '324 309 317'
3737

3838

3939
# --------------------------------------------------
4040
def test_fox():
4141
"""File"""
4242

43-
out = getoutput('{} {}'.format(prg, fox))
43+
out = getoutput(f'{prg} {fox}')
4444
assert out.strip() == '289 541 552 333 559 444 321 448 314'
4545

4646

4747
# --------------------------------------------------
4848
def test_spiders():
4949
"""File"""
5050

51-
out = getoutput('{} {}'.format(prg, spiders))
51+
out = getoutput(f'{prg} {spiders}')
5252
assert out.strip() == '405 579 762\n73 421 548\n862'
5353

5454

5555
# --------------------------------------------------
5656
def test_sonnet():
5757
"""File"""
5858

59-
out = getoutput('{} {}'.format(prg, sonnet))
59+
out = getoutput(f'{prg} {sonnet}')
6060
expected = """
6161
631 107
6262
719 1132

0 commit comments

Comments
 (0)