6
6
import random
7
7
from subprocess import getstatusoutput
8
8
9
- prg = ' ./ransom.py'
10
- fox = ' ../inputs/fox .txt'
11
- now = ' ../inputs/now .txt'
9
+ PRG = " ./ransom.py"
10
+ FOX = " ../inputs/FOX .txt"
11
+ NOW = " ../inputs/NOW .txt"
12
12
13
13
14
14
# --------------------------------------------------
15
15
def seed_flag ():
16
- return '-s' if random .randint (0 , 1 ) else '--seed'
16
+ """seed"""
17
+ return "-s" if random .randint (0 , 1 ) else "--seed"
17
18
18
19
19
20
# --------------------------------------------------
20
21
def test_exists ():
21
22
"""exists"""
22
23
23
- assert os .path .isfile (prg )
24
+ assert os .path .isfile (PRG )
24
25
25
26
26
27
# --------------------------------------------------
27
28
def test_usage ():
28
29
"""usage"""
29
30
30
- for flag in ['-h' , ' --help' ]:
31
- rv , out = getstatusoutput (f' { prg } { flag } ' )
31
+ for flag in ["-h" , " --help" ]:
32
+ rv , out = getstatusoutput (f"python { PRG } { flag } " )
32
33
assert rv == 0
33
34
assert re .match ("usage" , out , re .IGNORECASE )
34
35
@@ -37,12 +38,14 @@ def test_usage():
37
38
def test_text1 ():
38
39
"""Test"""
39
40
40
- in_text = 'The quick brown fox jumps over the lazy dog.'
41
- tests = [('1' , 'thE QUICk BrOWn Fox jumpS OveR tHe LAzY dOg.' ),
42
- ('3' , 'thE quICk BROwn Fox jUmPS OVEr the lAZY DOG.' )]
41
+ in_text = "The quick brown FOX jumps over the lazy dog."
42
+ tests = [
43
+ ("1" , "thE QUICk BrOWn Fox jumpS OveR tHe LAzY dOg." ),
44
+ ("3" , "thE quICk BROwn Fox jUmPS OVEr the lAZY DOG." ),
45
+ ]
43
46
44
47
for seed , expected in tests :
45
- rv , out = getstatusoutput (f'{ prg } { seed_flag ()} { seed } "{ in_text } "' )
48
+ rv , out = getstatusoutput (f'python { PRG } { seed_flag ()} { seed } "{ in_text } "' )
46
49
assert rv == 0
47
50
assert out .strip () == expected
48
51
@@ -51,16 +54,14 @@ def test_text1():
51
54
def test_text2 ():
52
55
"""Test"""
53
56
54
- in_text = ' Now is the time for all good men to come to the aid of the party.'
57
+ in_text = " Now is the time for all good men to come to the aid of the party."
55
58
tests = [
56
- ('2' ,
57
- 'now iS the TIME fOR ALl good meN TO COMe To THE AID oF THE PArTY.' ),
58
- ('5' ,
59
- 'NOw is tHE Time FOr all good men To coME TO tHe AiD OF THe ParTy.' )
59
+ ("2" , "now iS the TIME fOR ALl good meN TO COMe To THE AID oF THE PArTY." ),
60
+ ("5" , "NOw is tHE Time FOr all good men To coME TO tHe AiD OF THe ParTy." ),
60
61
]
61
62
62
63
for seed , expected in tests :
63
- rv , out = getstatusoutput (f'{ prg } { seed_flag ()} { seed } "{ in_text } "' )
64
+ rv , out = getstatusoutput (f'python { PRG } { seed_flag ()} { seed } "{ in_text } "' )
64
65
assert rv == 0
65
66
assert out .strip () == expected
66
67
@@ -69,11 +70,13 @@ def test_text2():
69
70
def test_file1 ():
70
71
"""Test"""
71
72
72
- tests = [('1' , 'thE QUICk BrOWn Fox jumpS OveR tHe LAzY dOg.' ),
73
- ('3' , 'thE quICk BROwn Fox jUmPS OVEr the lAZY DOG.' )]
73
+ tests = [
74
+ ("1" , "thE QUICk BrOWn Fox jumpS OveR tHe LAzY dOg." ),
75
+ ("3" , "thE quICk BROwn Fox jUmPS OVEr the lAZY DOG." ),
76
+ ]
74
77
75
78
for seed , expected in tests :
76
- rv , out = getstatusoutput (f' { prg } { seed_flag ()} { seed } { fox } ' )
79
+ rv , out = getstatusoutput (f"python { PRG } { seed_flag ()} { seed } { FOX } " )
77
80
assert rv == 0
78
81
assert out .strip () == expected
79
82
@@ -83,13 +86,11 @@ def test_file2():
83
86
"""Test"""
84
87
85
88
tests = [
86
- ('2' ,
87
- 'now iS the TIME fOR ALl good meN TO COMe To THE AID oF THE PArTY.' ),
88
- ('5' ,
89
- 'NOw is tHE Time FOr all good men To coME TO tHe AiD OF THe ParTy.' )
89
+ ("2" , "now iS the TIME fOR ALl good meN TO COMe To THE AID oF THE PArTY." ),
90
+ ("5" , "NOw is tHE Time FOr all good men To coME TO tHe AiD OF THe ParTy." ),
90
91
]
91
92
92
93
for seed , expected in tests :
93
- rv , out = getstatusoutput (f' { prg } { seed_flag ()} { seed } { now } ' )
94
+ rv , out = getstatusoutput (f"python { PRG } { seed_flag ()} { seed } { NOW } " )
94
95
assert rv == 0
95
96
assert out .strip () == expected
0 commit comments