Commit 14c3970e authored by Sean Leavey's avatar Sean Leavey

Refactor test for better error messages

parent d7cae420
import finesse.tracing.ctracer as ctracer
def trees_equal(t1, t2):
if t1 is None and t2 is None:
return True
def assert_trees_equal(t1, t2):
# Both t1 and t2 must be None or not None.
if t1 is None or t2 is None:
# Nothing to test.
return
elif (t1 is None and t2 is not None) or (t1 is not None and t2 is None):
assert False
if t1.node != t2.node or t1.dependency != t2.dependency:
return False
assert t1.node == t2.node, f"{t1} node {t1.node} != {t2} node {t2.node}"
assert (
t1.dependency == t2.dependency
), f"{t1} dependency {t1.dependency} != {t2} dependency {t2.dependency}"
return trees_equal(t1.left, t2.left) and trees_equal(t1.right, t2.right)
assert_trees_equal(t1.left, t2.left)
assert_trees_equal(t1.right, t2.right)
def test_fp_cavity_forest(model):
......@@ -41,7 +48,7 @@ def test_fp_cavity_forest(model):
assert len(forest) == len(model._trace_forest.forest)
for tree, ttree in zip(forest, model._trace_forest.forest):
assert trees_equal(tree, ttree)
assert_trees_equal(tree, ttree)
def test_fp_cavity_with_laser_gauss_forest(model):
......@@ -79,7 +86,7 @@ def test_fp_cavity_with_laser_gauss_forest(model):
assert len(forest) == len(model._trace_forest.forest)
for tree, ttree in zip(forest, model._trace_forest.forest):
assert trees_equal(tree, ttree)
assert_trees_equal(tree, ttree)
def test_mfp_forest(model):
......@@ -143,7 +150,7 @@ def test_mfp_forest(model):
assert len(forest) == len(model._trace_forest.forest)
for tree, ttree in zip(forest, model._trace_forest.forest):
assert trees_equal(tree, ttree)
assert_trees_equal(tree, ttree)
# TODO (sjr) Lots more potential configurations but main things to focus on are:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment