Reset IDs for tests that instantiate models directly

This commit is contained in:
Paul Romano 2018-01-29 11:39:37 -06:00
parent 98d5496102
commit 73947ad7de
17 changed files with 32 additions and 27 deletions

View file

@ -31,7 +31,7 @@ class FixedSourceTestHarness(PyAPITestHarness):
return outstr
def test_fixed_source(request):
def test_fixed_source(request, reset_ids):
mat = openmc.Material()
mat.add_nuclide('O16', 1.0)
mat.add_nuclide('U238', 0.0001)

View file

@ -3,7 +3,7 @@ from openmc.examples import slab_mg
from tests.testing_harness import PyAPITestHarness
def test_mg_basic(request):
def test_mg_basic(request, reset_ids):
model = slab_mg()
harness = PyAPITestHarness('statepoint.10.h5', model)
harness.request = request

View file

@ -3,7 +3,7 @@ from openmc.examples import slab_mg
from tests.testing_harness import PyAPITestHarness
def test_mg_legendre(request):
def test_mg_legendre(request, reset_ids):
model = slab_mg(reps=['iso'])
model.settings.tabular_legendre = {'enable': False}

View file

@ -3,7 +3,7 @@ from openmc.examples import slab_mg
from tests.testing_harness import PyAPITestHarness
def test_mg_max_order(request):
def test_mg_max_order(request, reset_ids):
model = slab_mg(reps=['iso'])
model.settings.max_order = 1
harness = PyAPITestHarness('statepoint.10.h5', model)

View file

@ -3,7 +3,7 @@ from openmc.examples import slab_mg
from tests.testing_harness import PyAPITestHarness
def test_mg_nuclide(request):
def test_mg_nuclide(request, reset_ids):
model = slab_mg(as_macro=False)
harness = PyAPITestHarness('statepoint.10.h5', model)
harness.request = request

View file

@ -3,7 +3,7 @@ from openmc.examples import slab_mg
from tests.testing_harness import PyAPITestHarness
def test_mg_survival_biasing(request):
def test_mg_survival_biasing(request, reset_ids):
model = slab_mg()
model.settings.survival_biasing = True
harness = PyAPITestHarness('statepoint.10.h5', model)

View file

@ -4,7 +4,7 @@ from openmc.examples import slab_mg
from tests.testing_harness import HashedPyAPITestHarness
def test_mg_tallies(request):
def test_mg_tallies(request, reset_ids):
model = slab_mg(as_macro=False)
# Instantiate a tally mesh

View file

@ -1,3 +1,5 @@
import os
import openmc
import openmc.mgxs
from openmc.examples import pwr_pin_cell
@ -52,8 +54,8 @@ class MGXSTestHarness(PyAPITestHarness):
self._model.materials.export_to_xml()
self._model.mgxs_file.export_to_hdf5()
# Dont need tallies.xml, so remove the file
if os.path.exists('./tallies.xml'):
os.remove('./tallies.xml')
if os.path.exists('tallies.xml'):
os.remove('tallies.xml')
# Enforce closing statepoint and summary files so HDF5
# does not throw an error during the next OpenMC execution
@ -69,12 +71,12 @@ class MGXSTestHarness(PyAPITestHarness):
def _cleanup(self):
super(MGXSTestHarness, self)._cleanup()
f = os.path.join(os.getcwd(), 'mgxs.h5')
f = 'mgxs.h5'
if os.path.exists(f):
os.remove(f)
def test_mgxs_library_ce_to_mg(request):
def test_mgxs_library_ce_to_mg(request, reset_ids):
# Set the input set to use the pincell model
model = pwr_pin_cell()

View file

@ -60,7 +60,7 @@ class MGXSTestHarness(PyAPITestHarness):
return outstr
def test_mgxs_library_condense(request):
def test_mgxs_library_condense(request, reset_ids):
# Use the pincell model
model = pwr_pin_cell()
harness = MGXSTestHarness('statepoint.10.h5', model)

View file

@ -64,7 +64,7 @@ class MGXSTestHarness(PyAPITestHarness):
return outstr
def test_mgxs_library_distribcell(request):
def test_mgxs_library_distribcell(request, reset_ids):
model = pwr_assembly()
harness = MGXSTestHarness('statepoint.10.h5', model)
harness.request = request

View file

@ -10,9 +10,6 @@ from openmc.examples import pwr_pin_cell
from tests.testing_harness import PyAPITestHarness
np.set_printoptions(formatter={'float_kind': '{:.8e}'.format})
class MGXSTestHarness(PyAPITestHarness):
def __init__(self, *args, **kwargs):
# Generate inputs using parent class routine
@ -76,8 +73,12 @@ class MGXSTestHarness(PyAPITestHarness):
os.remove(f)
def test_mgxs_library_hdf5(request):
model = pwr_pin_cell()
harness = MGXSTestHarness('statepoint.10.h5', model)
harness.request = request
harness.main()
def test_mgxs_library_hdf5(request, reset_ids):
try:
np.set_printoptions(formatter={'float_kind': '{:.8e}'.format})
model = pwr_pin_cell()
harness = MGXSTestHarness('statepoint.10.h5', model)
harness.request = request
harness.main()
finally:
np.set_printoptions(formatter=None)

View file

@ -57,7 +57,8 @@ class MGXSTestHarness(PyAPITestHarness):
return outstr
if __name__ == '__main__':
def test_mgxs_library_no_nuclides(request, reset_ids):
model = pwr_pin_cell()
harness = MGXSTestHarness('statepoint.10.h5', model)
harness.request = request
harness.main()

View file

@ -53,7 +53,8 @@ class MGXSTestHarness(PyAPITestHarness):
return outstr
if __name__ == '__main__':
def test_mgxs_library_nuclides(request, reset_ids):
model = pwr_pin_cell()
harness = MGXSTestHarness('statepoint.10.h5', model)
harness.request = request
harness.main()

View file

@ -80,7 +80,7 @@ class MultipoleTestHarness(PyAPITestHarness):
return outstr
def test_multipole(request):
def test_multipole(request, reset_ids):
model = make_model()
harness = MultipoleTestHarness('statepoint.5.h5', model)
harness.request = request

View file

@ -73,7 +73,7 @@ def make_model():
return model
def test_salphabeta(request):
def test_salphabeta(request, reset_ids):
model = make_model()
harness = PyAPITestHarness('statepoint.5.h5', model)
harness.request = request

View file

@ -4,7 +4,7 @@ from openmc import Mesh, Tally, Tallies
from tests.testing_harness import HashedPyAPITestHarness
def test_tallies(request):
def test_tallies(request, reset_ids):
harness = HashedPyAPITestHarness('statepoint.5.h5')
harness.request = request
model = harness._model

View file

@ -41,7 +41,7 @@ class TrackTestHarness(TestHarness):
def test_track_output(request):
# If vtk python module is not available, we can't run track.py so skip this
# test.
vtk = pytest.importerskip('vtk')
vtk = pytest.importorskip('vtk')
harness = TrackTestHarness('statepoint.2.h5')
harness.request = request
harness.main()