diff --git a/tests/analysis/elasticity/test_elastic.py b/tests/analysis/elasticity/test_elastic.py index 4fe8ecdc5da..10f2b9c2296 100644 --- a/tests/analysis/elasticity/test_elastic.py +++ b/tests/analysis/elasticity/test_elastic.py @@ -182,7 +182,7 @@ def test_new(self): UserWarning, match="Input elastic tensor does not satisfy standard Voigt symmetries" ) as warns: ElasticTensor(non_symm) - assert len(warns) == 1 + assert sum("Input elastic tensor does not satisfy standard Voigt symmetries" in str(warn) for warn in warns) == 1 bad_tensor1 = np.zeros((3, 3, 3)) bad_tensor2 = np.zeros((3, 3, 3, 2)) @@ -220,7 +220,8 @@ def test_from_independent_strains(self): stresses = self.toec_dict["stresses"] with pytest.warns(UserWarning, match="No eq state found, returning zero voigt stress") as warns: et = ElasticTensor.from_independent_strains(strains, stresses) - assert len(warns) == 2 + assert sum("No eq state found" in str(warn) for warn in warns) == 1 + assert sum("Extra strain states in strain-" in str(warn) for warn in warns) == 1 assert_allclose(et.voigt, self.toec_dict["C2_raw"], atol=1e1) def test_energy_density(self):