Skip to content

Commit 51e2c1e

Browse files
committed
refactor(test_parameters): use simple_param fixture in test_repr
1 parent 978b152 commit 51e2c1e

File tree

2 files changed

+12
-6
lines changed

2 files changed

+12
-6
lines changed

tests/unit/test_parameters/conftest.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import numpy as np
22
import pytest
33

4+
import pybamm
5+
46

57
@pytest.fixture
68
def assert_is_ndarray():
@@ -14,3 +16,8 @@ def _assert(obj):
1416
assert isinstance(obj, np.ndarray)
1517

1618
return _assert
19+
20+
21+
@pytest.fixture
22+
def simple_param():
23+
return pybamm.ParameterValues({"a": 1})

tests/unit/test_parameters/test_parameter_values.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,19 +41,18 @@ def test_init(self):
4141
with pytest.raises(ValueError, match="'Junk' is not a valid parameter set."):
4242
pybamm.ParameterValues("Junk")
4343

44-
def test_repr(self):
45-
param = pybamm.ParameterValues({"a": 1})
46-
assert "'a': 1" in repr(param)
47-
assert param._ipython_key_completions_() == [
44+
def test_repr(self, simple_param):
45+
assert "'a': 1" in repr(simple_param)
46+
assert simple_param._ipython_key_completions_() == [
4847
"Ideal gas constant [J.K-1.mol-1]",
4948
"Faraday constant [C.mol-1]",
5049
"Boltzmann constant [J.K-1]",
5150
"Electron charge [C]",
5251
"a",
5352
]
5453

55-
def test_eq(self):
56-
assert pybamm.ParameterValues({"a": 1}) == pybamm.ParameterValues({"a": 1})
54+
def test_eq(self, simple_param):
55+
assert simple_param == pybamm.ParameterValues({"a": 1})
5756

5857
def test_update(self):
5958
# equate values

0 commit comments

Comments
 (0)