5
5
import re
6
6
from subprocess import getstatusoutput , getoutput
7
7
8
- prg = ' ./scrambler.py'
9
- fox = ' ../inputs/fox.txt'
10
- bustle = ' ../inputs/the-bustle.txt'
11
- spiders = ' ../inputs/spiders.txt'
8
+ PRG = " ./scrambler.py"
9
+ FOX = " ../inputs/fox.txt"
10
+ BUSTLE = " ../inputs/the-bustle.txt"
11
+ SPIDERS = " ../inputs/spiders.txt"
12
12
13
13
14
14
# --------------------------------------------------
15
15
def test_exists ():
16
16
"""exists"""
17
17
18
- assert os .path .isfile (prg )
18
+ assert os .path .isfile (PRG )
19
19
20
20
21
21
# --------------------------------------------------
22
22
def test_usage ():
23
23
"""usage"""
24
24
25
- for flag in ['-h' , ' --help' ]:
26
- rv , out = getstatusoutput (f' { prg } { flag } ' )
25
+ for flag in ["-h" , " --help" ]:
26
+ rv , out = getstatusoutput (f"python { PRG } { flag } " )
27
27
assert rv == 0
28
28
assert re .match ("usage" , out , re .IGNORECASE )
29
29
@@ -32,17 +32,17 @@ def test_usage():
32
32
def test_text1 ():
33
33
"""Text"""
34
34
35
- out = getoutput (f' { prg } foobar -s 1' )
36
- assert out .strip () == ' faobor'
35
+ out = getoutput (f"python { PRG } foobar -s 1" )
36
+ assert out .strip () == " faobor"
37
37
38
38
39
39
# --------------------------------------------------
40
40
def test_text2 ():
41
41
"""Text"""
42
42
43
- text = ' The quick brown fox jumps over the lazy dog.'
44
- expected = ' The qicuk bworn fox jpmus over the lzay dog.'
45
- out = getoutput (f'{ prg } "{ text } " -s 2' )
43
+ text = " The quick brown fox jumps over the lazy dog."
44
+ expected = " The qicuk bworn fox jpmus over the lzay dog."
45
+ out = getoutput (f'python { PRG } "{ text } " -s 2' )
46
46
assert out .strip () == expected
47
47
48
48
@@ -62,22 +62,22 @@ def test_file_bustle():
62
62
Unitl eettnriy.
63
63
""" .strip ()
64
64
65
- out = getoutput (f' { prg } --seed 3 { bustle } ' )
65
+ out = getoutput (f"python { PRG } --seed 3 { BUSTLE } " )
66
66
assert out .strip () == expected .strip ()
67
67
68
68
69
69
# --------------------------------------------------
70
70
def test_file_fox ():
71
71
"""File input"""
72
72
73
- out = getoutput (f' { prg } --seed 4 { fox } ' )
74
- assert out .strip () == ' The qciuk bworn fox jpums oevr the lzay dog.'
73
+ out = getoutput (f"python { PRG } --seed 4 { FOX } " )
74
+ assert out .strip () == " The qciuk bworn fox jpums oevr the lzay dog."
75
75
76
76
77
77
# --------------------------------------------------
78
78
def test_file_spiders ():
79
79
"""File input"""
80
80
81
- out = getoutput (f' { prg } --seed 9 { spiders } ' )
81
+ out = getoutput (f"python { PRG } --seed 9 { SPIDERS } " )
82
82
expected = "Do'nt wrory, sedrpis,\n I keep hsoue\n calusaly."
83
83
assert out .strip () == expected
0 commit comments