@@ -35,6 +35,42 @@ def test_assign_functions_to_species():
35
35
assert isinstance (spe .test_function , ufl .Argument )
36
36
37
37
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
+
38
74
def test_implicit_species_concentration ():
39
75
"""Test that the concentration of an implicit species is computed
40
76
correctly.
0 commit comments