From 3d4d160941edc47d26b21457c792187256f55886 Mon Sep 17 00:00:00 2001 From: Janosh Riebesell Date: Wed, 17 May 2023 17:24:05 -0700 Subject: [PATCH] add test_symbol_oxi_state_str() --- pymatgen/core/tests/test_periodic_table.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/pymatgen/core/tests/test_periodic_table.py b/pymatgen/core/tests/test_periodic_table.py index 40a5901ad7e..192d7cda27a 100644 --- a/pymatgen/core/tests/test_periodic_table.py +++ b/pymatgen/core/tests/test_periodic_table.py @@ -543,5 +543,25 @@ def test_get_el_sp(self): assert get_el_sp("Mn3+") == Species("Mn", 3) +@pytest.mark.parametrize( + ("symbol_oxi", "expected_element", "expected_oxi_state"), + [ + ("Fe", "Fe", None), + ("Fe2+", "Fe", 2), + ("O2-", "O", -2), + ("N-", "N", -1), + ("Ca+", "Ca", 1), + ("Te3+", "Te", 3), + ("P5+", "P", 5), + ("Na0+", "Na", 0), + ("Na0-", "Na", 0), + ], +) +def test_symbol_oxi_state_str(symbol_oxi, expected_element, expected_oxi_state): + species = Species(symbol_oxi) + assert species._el.symbol == expected_element + assert species._oxi_state == expected_oxi_state + + if __name__ == "__main__": unittest.main()