Change test order to run unit tests first. (#3533)

Co-authored-by: Paul Romano <paul.k.romano@gmail.com>
This commit is contained in:
GuySten 2025-08-30 05:39:46 +02:00 committed by GitHub
parent ec15803d41
commit 00edc77691
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 11 additions and 10 deletions

View file

@ -567,10 +567,10 @@ class Cell(IDManagerMixin):
.. versionadded:: 0.14.0
"""
# Create dummy universe but preserve used_ids
next_id = openmc.Universe.next_id
next_id = openmc.UniverseBase.next_id
u = openmc.Universe(cells=[self])
openmc.Universe.used_ids.remove(u.id)
openmc.Universe.next_id = next_id
openmc.UniverseBase.used_ids.remove(u.id)
openmc.UniverseBase.next_id = next_id
return u.plot(*args, **kwargs)
def create_xml_subelement(self, xml_element, memo=None):

View file

@ -178,7 +178,7 @@ class _Config(MutableMapping):
self[key] = previous_value
def _default_config() -> _Config:
def _default_config(**kwargs) -> _Config:
"""Create a configuration initialized from environment variables.
This function checks for OPENMC_CROSS_SECTIONS, OPENMC_MG_CROSS_SECTIONS,
@ -192,11 +192,11 @@ def _default_config() -> _Config:
A new configuration object.
"""
config = _Config()
config = _Config(kwargs)
for key,var in _Config._PATH_KEYS.items():
if var in os.environ:
config[key] = os.environ[var]
chain_file = config.get("chain_file")
xs_path = config.get("cross_sections")
if chain_file is None and xs_path is not None and xs_path.exists():

View file

@ -13,6 +13,7 @@ def reset_config_and_env():
"""A fixture to ensure each test has a clean config, env, and CWD."""
original_env = dict(os.environ)
original_cwd = os.getcwd()
original_resolve_paths = openmc.config["resolve_paths"]
# Reset environment variables that affect config
for key in ['OPENMC_CROSS_SECTIONS', 'OPENMC_MG_CROSS_SECTIONS', 'OPENMC_CHAIN_FILE']:
@ -25,13 +26,13 @@ def reset_config_and_env():
try:
yield
finally:
# Restore environment and CWD
# Restore environment, CWD and resolve_paths
os.environ.clear()
os.environ.update(original_env)
os.chdir(original_cwd)
# Restore config one last time for safety between modules
openmc.config = _default_config()
openmc.config = _default_config(resolve_paths=original_resolve_paths)
def test_config_basics():

View file

@ -14,5 +14,5 @@ if [[ $EVENT == 'y' ]]; then
args="${args} --event "
fi
# Run regression and unit tests
pytest --cov=openmc -v $args tests
# Run unit tests and then regression tests
pytest --cov=openmc -v $args tests/unit_tests tests/regression_tests