def test_copy(self): dipole = Dipole(rho_dipole, angle_dipole) copy = dipole.copy() assert copy.rho == dipole.rho assert copy.theta == dipole.theta assert copy.name == dipole.name # make sure that if the instance's attribute is changed # copying takes the new values. dipole = Dipole(rho_dipole, angle_dipole) dipole.rho = 2 * dipole.rho dipole.theta = 2 * dipole.theta copy = dipole.copy() assert copy.rho == dipole.rho assert copy.theta == dipole.theta assert copy.name == dipole.name
def test_serialize(self): dipole = Dipole(rho_dipole, angle_dipole) dic = dipole._serialize() assert dic["element"] == "Dipole" assert dic["rho"] == rho_dipole assert dic["theta"] == angle_dipole assert dic["name"] == dipole.name # make sure that if the instance's attribute is changed # the serialization takes the new values. dipole = Dipole(rho_dipole, angle_dipole) dipole.rho = 2 * dipole.rho dipole.theta = 2 * dipole.theta dic = dipole._serialize() assert dic["element"] == "Dipole" assert dic["rho"] == dipole.rho assert dic["theta"] == dipole.theta assert dic["name"] == dipole.name