From 4b62006d23f679aa0ce7a089c4df1e7a674c619f Mon Sep 17 00:00:00 2001 From: Sterling Harper Date: Wed, 8 Aug 2018 10:54:53 -0400 Subject: [PATCH] Fix capi restart unit test --- tests/unit_tests/test_capi.py | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/tests/unit_tests/test_capi.py b/tests/unit_tests/test_capi.py index 288676ff7a..4b80ba7eb3 100644 --- a/tests/unit_tests/test_capi.py +++ b/tests/unit_tests/test_capi.py @@ -313,10 +313,14 @@ def test_mesh(capi_init): assert msf.mesh == mesh -def test_restart(pincell_model): - # Run for 7 batches then write a statepoint. +def test_restart(capi_init): + # Finalize and re-init to make internal state consistent with XML. + openmc.capi.hard_reset() + openmc.capi.finalize() openmc.capi.init() openmc.capi.simulation_init() + + # Run for 7 batches then write a statepoint. for i in range(7): openmc.capi.next_batch() openmc.capi.statepoint_write('restart_test.h5', True) @@ -325,17 +329,17 @@ def test_restart(pincell_model): for i in range(3): openmc.capi.next_batch() keff0 = openmc.capi.keff() - openmc.capi.simulation_finalize() - openmc.capi.finalize() - # Restart the simulation and run all 10 batches. + # Restart the simulation from the statepoint and run all 10 batches. + openmc.capi.simulation_finalize() + openmc.capi.hard_reset() + openmc.capi.finalize() openmc.capi.init(args=('-r', 'restart_test.h5')) openmc.capi.simulation_init() for i in range(10): openmc.capi.next_batch() keff1 = openmc.capi.keff() openmc.capi.simulation_finalize() - openmc.capi.finalize() # Compare the keff values. assert keff0 == pytest.approx(keff1)