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
·
140 lines (107 loc) · 3.34 KB

File metadata and controls

executable file
·
140 lines (107 loc) · 3.34 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
134
135
136
137
138
139
140
#!/usr/bin/env python3
"""tests for wod.py"""
import os
import random
import re
import string
from subprocess import getstatusoutput
prg = './wod.py'
input1 = 'inputs/exercises.csv'
input2 = 'inputs/silly-exercises.csv'
# --------------------------------------------------
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 out.lower().startswith('usage')
# --------------------------------------------------
def test_bad_num():
"""Dies on bad --num"""
bad = random.choice(range(-10, 0))
rv, out = getstatusoutput(f'{prg} -n {bad}')
assert rv != 0
assert re.search(f'--num "{bad}" must be greater than 0', out)
# --------------------------------------------------
def test_bad_file():
"""Dies on bad file"""
bad = random_string()
rv, out = getstatusoutput(f'{prg} -f {bad}')
assert rv != 0
assert re.search(f"No such file or directory: '{bad}'", out)
# --------------------------------------------------
def test_seed1():
"""Runs OK"""
expected = """
Exercise Reps
---------- ------
Pushups 56
Situps 88
Crunches 27
Burpees 35
"""
seed_flag = '-s' if random.choice([0, 1]) else '--seed'
rv, out = getstatusoutput(f'{prg} {seed_flag} 1')
assert rv == 0
assert out.strip() == expected.strip()
# --------------------------------------------------
def test_seed1_easy():
"""Runs OK"""
expected = """
Exercise Reps
---------- ------
Pushups 28
Situps 44
Crunches 13
Burpees 17
"""
seed_flag = '-s' if random.choice([0, 1]) else '--seed'
easy_flag = '-e' if random.choice([0, 1]) else '--easy'
rv, out = getstatusoutput(f'{prg} {easy_flag} {seed_flag} 1')
assert rv == 0
assert out.strip() == expected.strip()
# --------------------------------------------------
def test_seed2_num8():
"""Runs OK"""
expected = """
Exercise Reps
------------------ ------
Burpees 39
Situps 42
Crunches 29
Pushups 68
Plank 35
Hand-stand pushups 18
Pullups 30
Lunges 32
"""
seed_flag = '-s' if random.choice([0, 1]) else '--seed'
num_flag = '-n' if random.choice([0, 1]) else '--num'
cmd = f'{prg} {num_flag} 8 {seed_flag} 2 -f {input1}'
rv, out = getstatusoutput(cmd)
assert rv == 0
assert out.strip() == expected.strip()
# --------------------------------------------------
def test_seed4_num3_input2():
"""Runs OK"""
expected = """
Exercise Reps
----------------- ------
Hanging Chads 86
Red Barchettas 50
Squatting Chinups 35
"""
seed_flag = '-s' if random.choice([0, 1]) else '--seed'
num_flag = '-n' if random.choice([0, 1]) else '--num'
rv, out = getstatusoutput(f'{prg} {num_flag} 3 {seed_flag} 4 -f {input2}')
assert rv == 0
assert out.strip() == expected.strip()
# --------------------------------------------------
def random_string():
"""generate a random string"""
k = random.randint(5, 10)
return ''.join(random.choices(string.ascii_letters + string.digits, k=k))
Morty Proxy This is a proxified and sanitized view of the page, visit original site.