From 61bce00f08bec4abc4b27085656b5f947c6ed999 Mon Sep 17 00:00:00 2001 From: Patrick Shriwise Date: Fri, 11 Mar 2022 14:33:59 -0600 Subject: [PATCH] Adding function to resolve the full path to the test data files. --- tests/unit_tests/weightwindows/test_wwinp_reader.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/tests/unit_tests/weightwindows/test_wwinp_reader.py b/tests/unit_tests/weightwindows/test_wwinp_reader.py index dde7356bb9..b9de6b329f 100644 --- a/tests/unit_tests/weightwindows/test_wwinp_reader.py +++ b/tests/unit_tests/weightwindows/test_wwinp_reader.py @@ -1,11 +1,9 @@ import numpy as np +from pathlib import Path import openmc import pytest -from openmc.weight_windows import wwinp_to_wws - - # check that we can successfully read wwinp files with the following contents: # # - neutrons on a rectilinear mesh @@ -93,12 +91,16 @@ def id_fn(params): elif suffix == 'p': return 'photon-only' +# function to resolve full path to the test data +def full_path(filename): + cwd = Path(__file__).parent.absolute() + return cwd / Path(filename) @pytest.mark.parametrize('wwinp_data', expected_results, ids=id_fn) def test_wwinp_reader(wwinp_data): wwinp_file, mesh, particle_types, energy_bounds = wwinp_data - wws = openmc.wwinp_to_wws(wwinp_file) + wws = openmc.wwinp_to_wws(full_path(wwinp_file)) for i, ww in enumerate(wws): e_bounds = energy_bounds[i] @@ -142,4 +144,4 @@ def test_wwinp_reader_failures(wwinp_data): filename, expected_failure = wwinp_data with pytest.raises(expected_failure): - _ = openmc.wwinp_to_wws(filename) + _ = openmc.wwinp_to_wws(full_path(filename))