Skip to content

Commit ec2d15e

Browse files
increased coverage
1 parent fd3b0ef commit ec2d15e

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

test/test_species.py

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,42 @@ def test_assign_functions_to_species():
3535
assert isinstance(spe.test_function, ufl.Argument)
3636

3737

38+
def test_species_repr_and_str():
39+
"""Test that the __repr__ and __str__ methods of the Species class returns the
40+
expected string.
41+
"""
42+
# create a species
43+
species = F.Species("A")
44+
45+
# check that the __repr__ method returns the expected string
46+
expected_repr = "Species(A)"
47+
assert repr(species) == expected_repr
48+
49+
# check that the __str__ method returns the expected string
50+
expected_str = "A"
51+
assert str(species) == expected_str
52+
53+
54+
def test_implicit_species_repr_and_str():
55+
"""Test that the __repr__ and __str__ methods of the ImplicitSpecies class
56+
returns the expected string.
57+
"""
58+
# create two species
59+
species1 = F.Species("A")
60+
species2 = F.Species("B")
61+
62+
# create an implicit species that depends on the two species
63+
implicit_species = F.ImplicitSpecies(3.0, [species1, species2], name="C")
64+
65+
# check that the __repr__ method returns the expected string
66+
expected_repr = f"ImplicitSpecies(C, 3.0, {[species1, species2]})"
67+
assert repr(implicit_species) == expected_repr
68+
69+
# check that the __str__ method returns the expected string
70+
expected_str = "C"
71+
assert str(implicit_species) == expected_str
72+
73+
3874
def test_implicit_species_concentration():
3975
"""Test that the concentration of an implicit species is computed
4076
correctly.

0 commit comments

Comments
 (0)