forked from sdas1/python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpass_check.py
More file actions
49 lines (31 loc) · 1.77 KB
/
pass_check.py
File metadata and controls
49 lines (31 loc) · 1.77 KB
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
from test_omitting_outliers import test_remove_outliers
from test_rigorous_ranking import test_compute_rank
from test_printing_primes import test_print_primes
import pytest
SUBTASKS = {
"Omitting Outliers": (test_remove_outliers, 10),
"Rigorous Ranking": (test_compute_rank, 10),
"Printing Primes": (test_print_primes, 10)
}
def test_entire_homework():
points_achieved = 0
points_possible = 0
print("Checking {} subtasks to see if you reached at least 2/3 of the possible points ...\n".format(len(SUBTASKS)))
for subtask_name, (subtask_test_function, subtask_points) in SUBTASKS.items():
points_possible += subtask_points
try:
subtask_test_function()
# this line will only be reached if no AssertionError or other Exception was thrown in test_function()
points_achieved += subtask_points
print("Subtask '{}' with {} points: All good here!".format(subtask_name, subtask_points))
except Exception:
print("Subtask '{}' with {} points: Something went wrong. Better run 'pytest' on the corresponding pytest file to learn more!".format(subtask_name, subtask_points))
if points_achieved >= (2/3) * points_possible:
print("\nCongratulations! You passed this homework with {} out of {} points.".format(points_achieved, points_possible))
print("Do not forget to commit and push the current state of your code - the pass is only official once you see the checkmark on GitHub!")
exit(0)
else:
print("\nSorry! You only achieved {} points which is less than 2/3 of the possible {} points.".format(points_achieved, points_possible))
exit(1)
if __name__ == "__main__":
test_entire_homework()