From 02c1b498c31191575dbdcfd4f4f31b1cb22c9cfe Mon Sep 17 00:00:00 2001 From: Ali Zaidi <41302741+azaidi06@users.noreply.github.com> Date: Fri, 13 Dec 2024 11:20:26 -0500 Subject: [PATCH] added variable elements to help with black code formatting issue, due to lines being too long with the new as_file(files(... paradigm needed --- idaes/apps/grid_integration/tests/test_integration.py | 8 ++++++-- idaes/tests/prescient/test_prescient.py | 4 +++- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/idaes/apps/grid_integration/tests/test_integration.py b/idaes/apps/grid_integration/tests/test_integration.py index 26e9ad0830..3de0101920 100644 --- a/idaes/apps/grid_integration/tests/test_integration.py +++ b/idaes/apps/grid_integration/tests/test_integration.py @@ -51,7 +51,9 @@ def data_path(self) -> Path: # where importlib.resources.path() requires the resource to be a file # directories are not supported and will raise an error if attempted - with as_file(files("idaes.tests.prescient.5bus").joinpath("__init__.py")) as pkg_file: + fname = "idaes.tests.prescient.5bus" + py_fname = "__init__.py" + with as_file(files(fname).joinpath(py_fname)) as pkg_file: prescient_5bus = Path(pkg_file).parent @@ -73,7 +75,9 @@ def self_scheduler_output_dir(self, tmp_path: Path) -> Path: @pytest.fixture def self_scheduler_plugin_path(self) -> Path: - with as_file(files("idaes.apps.grid_integration.tests").joinpath("self_scheduler_integration_test_plugin.py")) as p: + fname = "idaes.apps.grid_integration.tests" + py_fname = "self_scheduler_integration_test_plugin.py" + with as_file(files(fname).joinpath(py_fname)) as p: return Path(p) @pytest.mark.unit diff --git a/idaes/tests/prescient/test_prescient.py b/idaes/tests/prescient/test_prescient.py index cf04d7e681..7ef1c71801 100644 --- a/idaes/tests/prescient/test_prescient.py +++ b/idaes/tests/prescient/test_prescient.py @@ -33,7 +33,9 @@ def data_path(self) -> Path: # we need to specify __init__.py as a workaround for Python 3.9, # where importlib.resources.path() requires the resource to be a file # directories are not supported and will raise an error if attempted - with as_file(files("idaes.tests.prescient.5bus").joinpath("__init__.py")) as pkg_file: + fname = "idaes.tests.prescient.5bus" + py_fname = "__init__.py" + with as_file(files(fname).joinpath(py_fname)) as pkg_file: prescient_5bus = Path(pkg_file).parent @pytest.mark.unit