def test_element_z(self): """Test element_z..................................................""" for z1, sym1, name1, mass1 in element._Z_SYMBOL_NAME_MASS: for sym2 in [sym1, sym1.lower(), sym1.upper()]: assert element.element_z(sym2) == z1 for name2 in [name1, name1.lower(), name1.upper()]: assert element.element_z(name2) == z1
def test_isotope_init_args(iso_str, sym, A, m): """Test Isotope init with 2 or 3 args, depending on whether m is None.""" sym = str(sym) name = element.element_name(sym) Z = element.element_z(sym) A = int(A) elems = [sym, sym.lower(), sym.upper(), name, name.lower(), name.upper(), Z, str(Z)] mass_numbers = [A, str(A)] if isinstance(m, int): if m == 0: m = "" else: m = "m{}".format(m) if m == "": isomer_levels = [None, "", 0] elif m.lower() == "m": isomer_levels = ["m", "M", 1] elif m.lower() == "m1": isomer_levels = ["m1", "M1"] else: isomer_levels = [m.lower(), m.upper(), int(m[1:])] for elem in elems: for mass in mass_numbers: for isomer in isomer_levels: args_list = [(elem, mass, isomer)] if isomer == "" or isomer is None: args_list.append((elem, mass)) for args in args_list: print("") print(args) i = isotope.Isotope(*args) print(i) assert i.symbol == sym assert i.A == A assert i.m == m
def test_element_z_exception(self): """Test element_z with bad input raises ElementZError..............""" for z1, sym1, name1, mass1 in element._Z_SYMBOL_NAME_MASS: with pytest.raises(element.ElementZError): element.element_z(z1)