-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtests.py
42 lines (35 loc) · 1.07 KB
/
tests.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
"""
Holds test classes and their respective methods.
"""
import unittest
from main import Solver
import constant
import helper
class TestLevels(unittest.TestCase):
"""
Contains test method(s) for testing levels.
"""
def test_levels_from_file(self):
"""
Test the levels from files, assert if all levels were solved.
"""
file_name = open('levels.txt', 'r')
count = 0
count_solved = 0
try:
for line in file_name.readlines():
main = Solver()
main.output = False
text = line.split(" ")[0]
grid = helper.create_grid_from_text(text, True)
matrix = helper.convert_to_matrix(grid, constant.BOARD_SIZE)
if main.solve(matrix):
count_solved += 1
count += 1
print(main.total_steps)
main.total_steps = 0
finally:
file_name.close()
self.assertEqual(count, count_solved)
if __name__ == '__main__':
unittest.main()