예제 #1
0
 def test_invalid_element_from_mass(self):
     with pytest.raises(ElementError):
         na = element_from_mass(22)
     with pytest.raises(TypeError):
         na = element_from_mass("11.0")
     with pytest.raises(TypeError):
         na = element_from_mass("sodium")
     with pytest.raises(TypeError):
         na = element_from_mass(22.99, duplicates="tuple")
     with pytest.raises(MultiMatchError):
         fl = element_from_mass(289.0)
예제 #2
0
 def test_element_attributes(self):
     na = element_from_mass(22.98)
     assert na.mass == 22.99
     assert na.atomic_number == 11
     assert na.name == "sodium"
     assert na.symbol == "Na"
     assert na.radius_bondi == 2.27
     assert na.radius_alvarez == 2.50
예제 #3
0
 def test_element_from_mass(self, Sodium, Magnesium):
     na = element_from_mass(22.98)
     assert na == Sodium
     with pytest.warns(UserWarning):
         mg = element_from_mass(24.0, exact=False)
     assert mg == Magnesium
     with pytest.warns(UserWarning):
         mg = element_from_mass(24, exact=False)
     assert mg == Magnesium
     elements = element_from_mass(289.0, duplicates="none")
     assert elements == None
     elements = element_from_mass(289.0, duplicates="all")
     fl = element_from_symbol("Fl")
     uup = element_from_symbol("Uup")
     assert elements == (fl, uup)
     elements = element_from_mass(288.5, duplicates="all", exact=False)
     assert elements == (fl, uup)
예제 #4
0
 def test_repr(self):
     na = element_from_mass(22.98)
     print(na)
예제 #5
0
 def test_element_attributes(self):
     na = element_from_mass(22.98)
     assert na.mass == 22.99
     assert na.atomic_number == 11
     assert na.name == "sodium"
     assert na.symbol == "Na"