Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Latest commit

 

History

History
History
executable file
·
133 lines (95 loc) · 3.07 KB

File metadata and controls

executable file
·
133 lines (95 loc) · 3.07 KB
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
#!/usr/bin/env python3
"""tests for abuse.py"""
import os
import random
import re
import string
from subprocess import getstatusoutput, getoutput
prg = './abuse.py'
# --------------------------------------------------
def test_exists():
"""exists"""
assert os.path.isfile(prg)
# --------------------------------------------------
def test_usage():
"""usage"""
for flag in ['-h', '--help']:
rv, out = getstatusoutput(f'{prg} {flag}')
assert rv == 0
assert re.match("usage", out, re.IGNORECASE)
# --------------------------------------------------
def test_bad_adjective_str():
"""bad_adjectives"""
bad = random_string()
rv, out = getstatusoutput(f'{prg} -a {bad}')
assert rv != 0
assert re.search(f"invalid int value: '{bad}'", out)
# --------------------------------------------------
def test_bad_adjective_num():
"""bad_adjectives"""
n = random.choice(range(-10, 0))
rv, out = getstatusoutput(f'{prg} -a {n}')
print(out)
assert rv != 0
assert re.search(f'--adjectives "{n}" must be > 0', out)
# --------------------------------------------------
def test_bad_number_str():
"""bad_number"""
bad = random_string()
rv, out = getstatusoutput(f'{prg} -n {bad}')
assert rv != 0
assert re.search(f"invalid int value: '{bad}'", out)
# --------------------------------------------------
def test_bad_number_int():
"""bad_number"""
n = random.choice(range(-10, 0))
rv, out = getstatusoutput(f'{prg} -n {n}')
assert rv != 0
assert re.search(f'--number "{n}" must be > 0', out)
# --------------------------------------------------
def test_bad_seed():
"""bad seed"""
bad = random_string()
rv, out = getstatusoutput(f'{prg} -s {bad}')
assert rv != 0
assert re.search(f"invalid int value: '{bad}'", out)
# --------------------------------------------------
def test_01():
"""test"""
out = getoutput(f'{prg} -s 1 -n 1')
assert out.strip() == 'You filthsome, cullionly fiend!'
# --------------------------------------------------
def test_02():
"""test"""
out = getoutput(f'{prg} --seed 2')
expected = """
You corrupt, detestable beggar!
You peevish, foolish gull!
You insatiate, heedless worm!
""".strip()
assert out.strip() == expected
# --------------------------------------------------
def test_03():
"""test"""
out = getoutput(f'{prg} -s 3 -n 5 -a 1')
expected = """
You infected villain!
You vile braggart!
You peevish worm!
You sodden-witted villain!
You cullionly worm!
""".strip()
assert out.strip() == expected
# --------------------------------------------------
def test_04():
"""test"""
out = getoutput(f'{prg} --seed 4 --number 2 --adjectives 4')
expected = """
You infected, lecherous, dishonest, rotten recreant!
You filthy, detestable, cullionly, base lunatic!
""".strip()
assert out.strip() == expected
# --------------------------------------------------
def random_string():
"""generate a random filename"""
return ''.join(random.choices(string.ascii_lowercase + string.digits, k=5))
Morty Proxy This is a proxified and sanitized view of the page, visit original site.