mirror of
https://github.com/openmc-dev/openmc.git
synced 2026-07-29 06:35:48 -04:00
Adding to regression test instead of making new unit test
This commit is contained in:
parent
9803c26111
commit
648313fab1
1 changed files with 27 additions and 0 deletions
|
|
@ -1,11 +1,14 @@
|
|||
import glob
|
||||
import os
|
||||
from pathlib import Path
|
||||
|
||||
import openmc
|
||||
|
||||
from tests.testing_harness import TestHarness
|
||||
from tests.regression_tests import config
|
||||
from tests import cdtemp
|
||||
|
||||
import pytest
|
||||
|
||||
class StatepointRestartTestHarness(TestHarness):
|
||||
def __init__(self, final_sp, restart_sp):
|
||||
|
|
@ -59,3 +62,27 @@ def test_statepoint_restart():
|
|||
harness = StatepointRestartTestHarness('statepoint.10.h5',
|
||||
'statepoint.07.h5')
|
||||
harness.main()
|
||||
|
||||
|
||||
def test_batch_check(request):
|
||||
xmls = glob.glob('*.xml')
|
||||
xmls = [request.fspath.dirpath() / Path(f) for f in xmls]
|
||||
|
||||
with cdtemp(xmls):
|
||||
model = openmc.Model.from_xml()
|
||||
model.settings.particles = 100
|
||||
# run the model
|
||||
sp_file = model.run()
|
||||
|
||||
# run a restart with the resulting statepoint
|
||||
# and the settings unchanged
|
||||
with pytest.raises(RuntimeError, match='is smaller than the number of batches'):
|
||||
model.run(restart_file=sp_file)
|
||||
|
||||
# update the number of batches and run again
|
||||
model.settings.batches = 15
|
||||
model.settings.statepoint = {}
|
||||
sp_file = model.run(restart_file=sp_file)
|
||||
|
||||
sp = openmc.StatePoint(sp_file)
|
||||
assert sp.n_batches == 15
|
||||
Loading…
Add table
Add a link
Reference in a new issue