mirror of
https://github.com/openmc-dev/openmc.git
synced 2026-07-28 14:15:42 -04:00
Adding tests for expected error messages
This commit is contained in:
parent
89fafb4fdf
commit
075ff0304c
1 changed files with 19 additions and 0 deletions
|
|
@ -11,6 +11,7 @@ pytestmark = pytest.mark.skipif(
|
|||
|
||||
@pytest.fixture
|
||||
def model():
|
||||
openmc.reset_auto_ids()
|
||||
|
||||
model = openmc.model.Model()
|
||||
|
||||
|
|
@ -56,6 +57,24 @@ def model():
|
|||
return model
|
||||
|
||||
|
||||
def test_missing_material_id(model):
|
||||
# remove the last material, which is identified by ID in the DAGMC file
|
||||
model.materials = model.materials[:-1]
|
||||
with pytest.raises(RuntimeError) as exec_info:
|
||||
model.run()
|
||||
exp_error_msg = "Material with ID '41' not found for volume (cell) 3"
|
||||
assert exp_error_msg in str(exec_info.value)
|
||||
|
||||
|
||||
def test_missing_material_name(model):
|
||||
# remove the first material, which is identified by name in the DAGMC file
|
||||
model.materials = model.materials[1:]
|
||||
with pytest.raises(RuntimeError) as exec_info:
|
||||
model.run()
|
||||
exp_error_msg = "No material 'no-void fuel' found for volume (cell) 1"
|
||||
assert exp_error_msg in str(exec_info.value)
|
||||
|
||||
|
||||
def test_dagmc(model):
|
||||
harness = PyAPITestHarness('statepoint.5.h5', model)
|
||||
harness.main()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue