7
7
import re
8
8
import string
9
9
10
- prg = "./telephone.py"
11
- fox = ' ../inputs/fox.txt'
12
- now = ' ../inputs/now.txt'
10
+ PRG = "./telephone.py"
11
+ FOX = " ../inputs/fox.txt"
12
+ NOW = " ../inputs/now.txt"
13
13
14
14
15
15
# --------------------------------------------------
16
16
def test_exists ():
17
17
"""exists"""
18
18
19
- assert os .path .isfile (prg )
19
+ assert os .path .isfile (PRG )
20
20
21
21
22
22
# --------------------------------------------------
23
23
def test_usage ():
24
24
"""usage"""
25
25
26
- for flag in ['' , '-h' , ' --help' ]:
27
- out = getoutput (f' { prg } { flag } ' )
28
- assert re .match (' usage' , out , re .IGNORECASE )
26
+ for flag in ["" , "-h" , " --help" ]:
27
+ out = getoutput (f"python3 { PRG } { flag } " )
28
+ assert re .match (" usage" , out , re .IGNORECASE )
29
29
30
30
31
31
# --------------------------------------------------
32
32
def test_bad_seed_str ():
33
33
"""bad seed str value"""
34
34
35
35
bad = random_string ()
36
- rv , out = getstatusoutput (f' { prg } -s { bad } { fox } ' )
36
+ rv , out = getstatusoutput (f"python3 { PRG } -s { bad } { FOX } " )
37
37
assert rv > 0
38
38
assert re .search (f"invalid int value: '{ bad } '" , out )
39
39
@@ -43,7 +43,7 @@ def test_bad_mutation_str():
43
43
"""bad mutation str value"""
44
44
45
45
bad = random_string ()
46
- rv , out = getstatusoutput (f' { prg } -m { bad } { fox } ' )
46
+ rv , out = getstatusoutput (f"python3 { PRG } -m { bad } { FOX } " )
47
47
assert rv > 0
48
48
assert re .search (f"invalid float value: '{ bad } '" , out )
49
49
@@ -52,18 +52,18 @@ def test_bad_mutation_str():
52
52
def test_bad_mutation ():
53
53
"""bad mutation values"""
54
54
55
- for val in [' -1.0' , ' 10.0' ]:
56
- rv , out = getstatusoutput (f' { prg } -m { val } { fox } ' )
55
+ for val in [" -1.0" , " 10.0" ]:
56
+ rv , out = getstatusoutput (f"python3 { PRG } -m { val } { FOX } " )
57
57
assert rv > 0
58
- assert re .search (f'--mutations "{ val } " must be between 0 and 1' , out )
58
+ assert re .search (f'--mutations: "{ val } " must be between 0 and 1' , out )
59
59
60
60
61
61
# --------------------------------------------------
62
62
def test_for_echo ():
63
63
"""test"""
64
64
65
- txt = open (now ).read ().rstrip ()
66
- rv , out = getstatusoutput (f'{ prg } -m 0 "{ txt } "' )
65
+ txt = open (NOW ).read ().rstrip ()
66
+ rv , out = getstatusoutput (f'python3 { PRG } -m 0 "{ txt } "' )
67
67
assert rv == 0
68
68
assert out .rstrip () == f'You said: "{ txt } "\n I heard : "{ txt } "'
69
69
@@ -72,8 +72,8 @@ def test_for_echo():
72
72
def test_now_cmd_s1 ():
73
73
"""test"""
74
74
75
- txt = open (now ).read ().rstrip ()
76
- rv , out = getstatusoutput (f'{ prg } -s 1 "{ txt } "' )
75
+ txt = open (NOW ).read ().rstrip ()
76
+ rv , out = getstatusoutput (f'python3 { PRG } -s 1 "{ txt } "' )
77
77
assert rv == 0
78
78
expected = """
79
79
Now is Ege time [dr all good me- to come to the jid of the party.
@@ -85,8 +85,8 @@ def test_now_cmd_s1():
85
85
def test_now_cmd_s2_m4 ():
86
86
"""test"""
87
87
88
- txt = open (now ).read ().rstrip ()
89
- rv , out = getstatusoutput (f'{ prg } -s 2 -m .4 "{ txt } "' )
88
+ txt = open (NOW ).read ().rstrip ()
89
+ rv , out = getstatusoutput (f'python3 { PRG } -s 2 -m .4 "{ txt } "' )
90
90
assert rv == 0
91
91
expected = """
92
92
No$ i% khefMiIe sor@all$glo<BmenYts cAAeltaTtheSaid[HYnthe Aalty.
@@ -98,9 +98,9 @@ def test_now_cmd_s2_m4():
98
98
def test_fox_file_s1 ():
99
99
"""test"""
100
100
101
- rv , out = getstatusoutput (f' { prg } --seed 1 { fox } ' )
101
+ rv , out = getstatusoutput (f"python3 { PRG } --seed 1 { FOX } " )
102
102
assert rv == 0
103
- txt = open (fox ).read ().rstrip ()
103
+ txt = open (FOX ).read ().rstrip ()
104
104
expected = "The duic: brown hox jumps over the lkzy dog."
105
105
assert out .rstrip () == f'You said: "{ txt } "\n I heard : "{ expected } "'
106
106
@@ -109,9 +109,9 @@ def test_fox_file_s1():
109
109
def test_fox_file_s2_m6 ():
110
110
"""test"""
111
111
112
- rv , out = getstatusoutput (f' { prg } --seed 2 --mutations .6 { fox } ' )
112
+ rv , out = getstatusoutput (f"python3 { PRG } --seed 2 --mutations .6 { FOX } " )
113
113
assert rv == 0
114
- txt = open (fox ).read ().rstrip ()
114
+ txt = open (FOX ).read ().rstrip ()
115
115
expected = "ZoA@qric` HwdTB Alx$jumIslolXs th^Yl?dy<YoA."
116
116
assert out .rstrip () == f'You said: "{ txt } "\n I heard : "{ expected } "'
117
117
@@ -120,4 +120,4 @@ def test_fox_file_s2_m6():
120
120
def random_string ():
121
121
"""generate a random filename"""
122
122
123
- return '' .join (random .choices (string .ascii_lowercase + string .digits , k = 5 ))
123
+ return "" .join (random .choices (string .ascii_lowercase + string .digits , k = 5 ))
0 commit comments