-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtest.py
58 lines (42 loc) · 1.44 KB
/
test.py
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
"""
Sudoku Generator
© Atomic Sorcerer 2022
"""
from lib.utils import generate_board
import sys
arg_iterations = 1000
try:
arg_iterations = int(sys.argv[1])
except IndexError:
pass
class ProgressBar:
def __init__(self, iterations, length=20):
self.iterations = iterations
self.length = length
self.tracker = 0
self.count = 0
def progress(self) -> None:
self.tracker += 1
if self.tracker % (self.iterations / self.length) == 0:
self.count += 1
print("\r", end="")
print(
f"{str(self.tracker)}/{str(self.iterations)} - [{'=' * self.count}{'*' * (self.length - self.count)}]",
end="",
)
def run_test_series(iterations_to_complete=100) -> tuple[float, int, list[str]]:
progress_bar = ProgressBar(iterations=iterations_to_complete)
error_count = 0
issues = []
for i in range(iterations_to_complete):
try:
generate_board(show_process=False, print_final_result=False)
except Exception as e:
error_count += 1
issues.append(e.__class__.__name__)
progress_bar.progress()
return error_count / iterations_to_complete, error_count, issues
error_rate = run_test_series(arg_iterations)
print("\n\n" + "Error Rate: " + str(round(error_rate[0] * 100, 4)) + "%")
print(f"An error was found {error_rate[1]} times.")
print(f"Error(s) found: { list(set(error_rate[2])) }")