From 4ef907bd5bd21fa09e058af0827691b5abc99cd3 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 10 Jul 2025 22:44:03 +0000 Subject: [PATCH] Add proper test isolation and error handling to random ray multiple point sources test Co-authored-by: jtramm <1009059+jtramm@users.noreply.github.com> --- .../test_random_ray_multiple_point_sources.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/tests/unit_tests/test_random_ray_multiple_point_sources.py b/tests/unit_tests/test_random_ray_multiple_point_sources.py index eea55a7a5..453dc6cf5 100644 --- a/tests/unit_tests/test_random_ray_multiple_point_sources.py +++ b/tests/unit_tests/test_random_ray_multiple_point_sources.py @@ -6,16 +6,19 @@ placed in the same subdivided source region would silently overwrite each other. The fix adds proper error detection to prevent this condition. """ +import os +import tempfile import pytest import openmc from openmc.examples import random_ray_three_region_cube -def test_multiple_point_sources_same_location_error(): +def test_multiple_point_sources_same_location_error(run_in_tmpdir): """Test that multiple point sources at the same location trigger an error when mesh subdivision is enabled.""" # Create a basic random ray model + openmc.reset_auto_ids() model = random_ray_three_region_cube() # Enable mesh subdivision - this is required to trigger the error @@ -59,11 +62,12 @@ def test_multiple_point_sources_same_location_error(): model.run() -def test_multiple_point_sources_different_locations_success(): +def test_multiple_point_sources_different_locations_success(run_in_tmpdir): """Test that multiple point sources at different locations work correctly with mesh subdivision enabled.""" # Create a basic random ray model + openmc.reset_auto_ids() model = random_ray_three_region_cube() # Enable mesh subdivision @@ -113,11 +117,12 @@ def test_multiple_point_sources_different_locations_success(): raise -def test_multiple_point_sources_no_mesh_subdivision_success(): +def test_multiple_point_sources_no_mesh_subdivision_success(run_in_tmpdir): """Test that multiple point sources at the same location work correctly when mesh subdivision is disabled.""" # Create a basic random ray model without mesh subdivision + openmc.reset_auto_ids() model = random_ray_three_region_cube() # Explicitly ensure no mesh subdivision is configured