From dd79f85e510b9d74247dd420e7be92feb4645012 Mon Sep 17 00:00:00 2001 From: Daniel Weindl Date: Tue, 26 Nov 2024 11:00:29 +0100 Subject: [PATCH] .. --- python/tests/conftest.py | 24 +++++++++++++++++++++--- python/tests/test_edata.py | 1 - python/tests/test_sbml_import.py | 18 ++---------------- 3 files changed, 23 insertions(+), 20 deletions(-) diff --git a/python/tests/conftest.py b/python/tests/conftest.py index d8d882fcfd..3d4856d084 100644 --- a/python/tests/conftest.py +++ b/python/tests/conftest.py @@ -7,7 +7,10 @@ import amici import pytest -from amici.testing import TemporaryDirectoryWinSafe +from amici.testing import TemporaryDirectoryWinSafe as TemporaryDirectory +from pathlib import Path + +EXAMPLES_DIR = Path(__file__).parent / ".." / "examples" @pytest.fixture(scope="session") @@ -32,7 +35,7 @@ def sbml_example_presimulation_module(): ) module_name = "test_model_presimulation" - with TemporaryDirectoryWinSafe(prefix=module_name) as outdir: + with TemporaryDirectory(prefix=module_name) as outdir: sbml_importer.sbml2amici( model_name=module_name, output_dir=outdir, @@ -71,7 +74,7 @@ def pysb_example_presimulation_module(): model.name = "test_model_presimulation_pysb" - with TemporaryDirectoryWinSafe(prefix=model.name) as outdir: + with TemporaryDirectory(prefix=model.name) as outdir: pysb2amici( model, outdir, @@ -81,3 +84,18 @@ def pysb_example_presimulation_module(): ) yield amici.import_model_module(model.name, outdir) + + +@pytest.fixture(scope="session") +def model_units_module(): + sbml_file = EXAMPLES_DIR / "example_units" / "model_units.xml" + module_name = "test_model_units" + + sbml_importer = amici.SbmlImporter(sbml_file) + + with TemporaryDirectory() as outdir: + sbml_importer.sbml2amici(model_name=module_name, output_dir=outdir) + + yield amici.import_model_module( + module_name=module_name, module_path=outdir + ) diff --git a/python/tests/test_edata.py b/python/tests/test_edata.py index 1e63b1c126..0baa7443fb 100644 --- a/python/tests/test_edata.py +++ b/python/tests/test_edata.py @@ -4,7 +4,6 @@ import numpy as np import pytest from amici.testing import skip_on_valgrind -from test_sbml_import import model_units_module # noqa: F401 @skip_on_valgrind diff --git a/python/tests/test_sbml_import.py b/python/tests/test_sbml_import.py index f253279be1..7a3f0a2720 100644 --- a/python/tests/test_sbml_import.py +++ b/python/tests/test_sbml_import.py @@ -16,7 +16,8 @@ from amici.testing import skip_on_valgrind from numpy.testing import assert_allclose, assert_array_equal -EXAMPLES_DIR = Path(__file__).parent / ".." / "examples" +from conftest import EXAMPLES_DIR + STEADYSTATE_MODEL_FILE = ( EXAMPLES_DIR / "example_steadystate" / "model_steadystate_scaled.xml" ) @@ -229,21 +230,6 @@ def model_steadystate_module(): ) -@pytest.fixture(scope="session") -def model_units_module(): - sbml_file = EXAMPLES_DIR / "example_units" / "model_units.xml" - module_name = "test_model_units" - - sbml_importer = amici.SbmlImporter(sbml_file) - - with TemporaryDirectory() as outdir: - sbml_importer.sbml2amici(model_name=module_name, output_dir=outdir) - - yield amici.import_model_module( - module_name=module_name, module_path=outdir - ) - - def test_presimulation(sbml_example_presimulation_module): """Test 'presimulation' test model""" model = sbml_example_presimulation_module.getModel()