Ejemplo n.º 1
0
def test_element(z, sym, name):
    """Run instantiation tests for various elements.

    Instantiate for element symbol and name, in mixed case, upper case,
    and lower case. Also by Z as both integer and string.
    """

    args = [name, name.lower(), name.upper()]
    args.extend([sym, sym.lower(), sym.upper()])
    args.extend([z, str(z)])
    print(args)
    for arg in args:
        print("")
        print("arg: ", arg)
        elem = element.Element(arg)
        print(elem)
        assert elem.Z == z
        assert elem.symbol == sym
        assert elem.name == name
Ejemplo n.º 2
0
 def test_og(self):
     """Test Element string formatting: Og.............................."""
     assert "{:%n (%s) %z}".format(element.Element("Og")) == "Oganesson (Og) 118"
Ejemplo n.º 3
0
 def test_h(self):
     """Test Element string formatting: H..............................."""
     assert "{:%n (%s) %z}".format(element.Element("H")) == "Hydrogen (H) 1"
Ejemplo n.º 4
0
 def test_bad(self):
     """Test Element equality: H != 0..................................."""
     with pytest.raises(element.ElementError):
         elem = element.Element("H")
         elem == 0
Ejemplo n.º 5
0
 def test_og(self):
     """Test Element equality: Og......................................."""
     assert element.Element("Og") == element.Element(118)
Ejemplo n.º 6
0
 def test_h(self):
     """Test Element equality: H........................................"""
     assert element.Element("H") == element.Element(1)
Ejemplo n.º 7
0
 def test_bad_arg_z(self):
     """Test Element init with a bad Z raises ElementError.............."""
     with pytest.raises(element.ElementError):
         element.Element(0)
Ejemplo n.º 8
0
 def test_bad_arg_name(self):
     """Test Element init with a bad name raises ElementError..........."""
     with pytest.raises(element.ElementError):
         element.Element("Xirconium")
Ejemplo n.º 9
0
 def test_bad_arg_symbol(self):
     """Test Element init with a bad symbol raises ElementError........."""
     with pytest.raises(element.ElementError):
         element.Element("Xx")
Ejemplo n.º 10
0
 def test_og(self):
     """Test Element string formatting: Og.............................."""
     assert '{:%n (%s) %z}'.format(element.Element('Og')) == \
         'Oganesson (Og) 118'
Ejemplo n.º 11
0
 def test_h(self):
     """Test Element string formatting: H..............................."""
     assert '{:%n (%s) %z}'.format(element.Element('H')) == \
         'Hydrogen (H) 1'