From d1e6a5a0938fee19fd6c61268930291476a8a40e Mon Sep 17 00:00:00 2001 From: Pradyot Ranjan <99216956+pradyotRanjan@users.noreply.github.com> Date: Sun, 1 Sep 2024 18:38:06 +0530 Subject: [PATCH 1/2] Trying to remove shared.py Signed-off-by: Pradyot Ranjan <99216956+pradyotRanjan@users.noreply.github.com> --- tests/conftest.py | 23 +++++++++++++++++++ .../test_interface/test_lead_acid.py | 5 ++-- 2 files changed, 25 insertions(+), 3 deletions(-) create mode 100644 tests/conftest.py diff --git a/tests/conftest.py b/tests/conftest.py new file mode 100644 index 0000000000..a0df7fef7e --- /dev/null +++ b/tests/conftest.py @@ -0,0 +1,23 @@ +import pytest +from tests.shared import ( + SpatialMethodForTesting, + get_mesh_for_testing, +) +import pybamm + + +@pytest.fixture(scope="module") +def get_discretisation_for_testing( + xpts=None, rpts=10, mesh=None, cc_method=SpatialMethodForTesting +): + if mesh is None: + mesh = get_mesh_for_testing(xpts=xpts, rpts=rpts) + spatial_methods = { + "macroscale": SpatialMethodForTesting(), + "negative particle": SpatialMethodForTesting(), + "positive particle": SpatialMethodForTesting(), + "negative particle size": SpatialMethodForTesting(), + "positive particle size": SpatialMethodForTesting(), + "current collector": cc_method(), + } + return pybamm.Discretisation(mesh, spatial_methods) diff --git a/tests/integration/test_models/test_submodels/test_interface/test_lead_acid.py b/tests/integration/test_models/test_submodels/test_interface/test_lead_acid.py index f0418f4bf7..0060a6eb1e 100644 --- a/tests/integration/test_models/test_submodels/test_interface/test_lead_acid.py +++ b/tests/integration/test_models/test_submodels/test_interface/test_lead_acid.py @@ -2,7 +2,6 @@ # Tests for the electrode-electrolyte interface equations for lead-acid models # import pybamm -from tests import get_discretisation_for_testing import pytest @@ -75,7 +74,7 @@ def test_set_parameters_main_reaction(self): for x in j0_p.pre_order(): assert not isinstance(x, pybamm.Parameter) - def test_discretisation_main_reaction(self): + def test_discretisation_main_reaction(self, get_discretisation_for_testing): # With intercalation param = pybamm.LeadAcidParameters() model_n = pybamm.interface.BaseInterface( @@ -88,7 +87,7 @@ def test_discretisation_main_reaction(self): j0_p = model_p._get_exchange_current_density(self.variables) # Process parameters and discretise parameter_values = pybamm.lead_acid.BaseModel().default_parameter_values - disc = get_discretisation_for_testing() + disc = get_discretisation_for_testing mesh = disc.mesh disc.set_variable_slices([self.c_e]) j0_n = disc.process_symbol(parameter_values.process_symbol(j0_n)) From bc335f1d4869267b180fe8130526ac2bd02e53fe Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Sun, 1 Sep 2024 13:10:50 +0000 Subject: [PATCH 2/2] style: pre-commit fixes --- tests/conftest.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/conftest.py b/tests/conftest.py index a0df7fef7e..798d682016 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -8,7 +8,7 @@ @pytest.fixture(scope="module") def get_discretisation_for_testing( - xpts=None, rpts=10, mesh=None, cc_method=SpatialMethodForTesting + xpts=None, rpts=10, mesh=None, cc_method=SpatialMethodForTesting ): if mesh is None: mesh = get_mesh_for_testing(xpts=xpts, rpts=rpts)