-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_examples.py
28 lines (22 loc) · 915 Bytes
/
test_examples.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
"""Tests for the puzzles, so I can refactor them without going crazy."""
import examples
import examples.puzzles.comets
def test_comets():
"""Assert the comets problem is solved correctly."""
statement = examples.puzzles.comets.comets()
solutions = examples.sat_utils.solve_all(statement)
assert len(solutions) == 1
readable_statement = examples._readable_cnf(solutions[0], separator="\n")
assertions = readable_statement.split("\n")
expected = [
"Casputi was discovered in 2009",
"Casputi was discovered by Hal Gregory",
"Crecci was discovered in 2010",
"Crecci was discovered by Underwood",
"Peinope was discovered in 2008",
"Peinope was discovered by Jack Ingram",
"Sporrin was discovered in 2011",
"Sporrin was discovered by Ken Jones",
]
for assertion in expected:
assert assertion in assertions