From b3225be24d384ba834fab6f003ff7ba39e9d99b1 Mon Sep 17 00:00:00 2001 From: Patrick Shriwise Date: Mon, 28 Nov 2022 20:03:42 -0600 Subject: [PATCH] Adding executor tests --- tests/unit_tests/test_model.py | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/tests/unit_tests/test_model.py b/tests/unit_tests/test_model.py index 87557ddc53..5d4765d657 100644 --- a/tests/unit_tests/test_model.py +++ b/tests/unit_tests/test_model.py @@ -1,5 +1,6 @@ from math import pi from pathlib import Path +import os import numpy as np import pytest @@ -546,4 +547,23 @@ def test_model_xml(run_in_tmpdir): # make sure we can also export this again to separate # XML files - new_model.export_to_xml(separate_xmls=True) \ No newline at end of file + new_model.export_to_xml(separate_xmls=True) + +def test_model_exec(run_in_tmpdir): + + pincell_model = openmc.examples.pwr_pin_cell() + + pincell_model.export_to_xml(filename='pwr_pincell.xml', separate_xmls=False) + + openmc.run(input_file='pwr_pincell.xml') + + with pytest.raises(RuntimeError, match='ex-em-ell.xml'): + openmc.run(input_file='ex-em-ell.xml') + + # test that a file in a different directory can be used + os.mkdir('inputs') + pincell_model.export_to_xml(directory='./inputs', filename='pincell.xml', separate_xmls=False) + openmc.run(input_file='./inputs/pincell.xml') + + with pytest.raises(RuntimeError, match='input_dir'): + openmc.run(input_file='input_dir/pincell.xml') \ No newline at end of file