Updating tests to reflect changes to API

This commit is contained in:
Patrick Shriwise 2022-12-06 14:41:26 -06:00
parent d639d1dc1b
commit 939adbe70e
2 changed files with 16 additions and 10 deletions

View file

@ -1,6 +1,8 @@
from difflib import unified_diff
import glob
import filecmp
import os
from pathlib import Path
import openmc
import pytest
@ -83,13 +85,17 @@ def test_input_arg(run_in_tmpdir):
pincell.export_to_xml(separate_xmls=True)
openmc.run()
# make sure the executable isn't falling back on the separate XMLs
[os.remove(f) for f in glob.glob('*.xml')]
# now export to a single XML file with a custom name
pincell.export_to_xml(filename='pincell.xml', separate_xmls=False)
pincell.export_to_xml(path='pincell.xml', separate_xmls=False)
assert Path('pincell.xml').exists()
# run by specifying that single file
openmc.run(input_file='pincell.xml')
openmc.run(path_input='pincell.xml')
# now ensure we get an error for an incorrect filename,
# even in the presence of other, valid XML files
pincell.export_to_xml(separate_xmls=True)
with pytest.raises(RuntimeError, match='ex-em-ell.xml'):
openmc.run(input_file='ex-em-ell.xml')
openmc.run(path_input='ex-em-ell.xml')

View file

@ -543,7 +543,7 @@ def test_model_xml(run_in_tmpdir):
# now write and read a model.xml file
pwr_model.export_to_xml(separate_xmls=False)
new_model = openmc.Model.from_xml(separate_xmls=False)
new_model = openmc.Model.from_model_xml()
# make sure we can also export this again to separate
# XML files
@ -553,17 +553,17 @@ 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)
pincell_model.export_to_xml(path='pwr_pincell.xml', separate_xmls=False)
openmc.run(input_file='pwr_pincell.xml')
openmc.run(path_input='pwr_pincell.xml')
with pytest.raises(RuntimeError, match='ex-em-ell.xml'):
openmc.run(input_file='ex-em-ell.xml')
openmc.run(path_input='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')
pincell_model.export_to_xml(path='./inputs/pincell.xml', separate_xmls=False)
openmc.run(path_input='./inputs/pincell.xml')
with pytest.raises(RuntimeError, match='input_dir'):
openmc.run(input_file='input_dir/pincell.xml')
openmc.run(path_input='input_dir/pincell.xml')