def test_register_is_false(self): sim1 = new_simulation(register=False) assert sim1 is not topo.sim sid = id(sim1['S']) sim2 = copy.copy(sim1) assert sim2 is not sim1 assert sim2 is not topo.sim sim3 = copy.deepcopy(sim1) assert sim3 is not sim1 assert sim3 is not topo.sim self.assertNotEqual(id(sim3['S']), sid) new_simulation(register=True) sim1['S'].precedence = 111 p = pickle.dumps(sim1, 2) topo.sim['S'].precedence = 5 sim4 = pickle.loads(p) assert sim4 is not sim1 assert sim4 is not topo.sim assert topo.sim['S'].precedence == 5
def test_register_is_false(self): sim1 = new_simulation(register=False) assert sim1 is not topo.sim sid = id(sim1['S']) sim2 = copy.copy(sim1) assert sim2 is not sim1 assert sim2 is not topo.sim sim3 = copy.deepcopy(sim1) assert sim3 is not sim1 assert sim3 is not topo.sim self.assertNotEqual(id(sim3['S']),sid) new_simulation(register=True) sim1['S'].precedence=111 p = pickle.dumps(sim1,2) topo.sim['S'].precedence=5 sim4 = pickle.loads(p) assert sim4 is not sim1 assert sim4 is not topo.sim assert topo.sim['S'].precedence==5
def test_link_to_topo_sim(self): """Indicate there's a bug. Have yet to investigate where it actually comes from.""" import topo from topo.tests.utils import new_simulation new_simulation() e = tk.edit_parameters(topo.sim['S']) e.gui_set_param('precedence',7) e.Apply() self.assertEqual(topo.sim['S'].precedence,7)
def test_link_to_topo_sim(self): """Indicate there's a bug. Have yet to investigate where it actually comes from.""" import topo from topo.tests.utils import new_simulation new_simulation() e = tk.edit_parameters(topo.sim['S']) e.gui_set_param('precedence', 7) e.Apply() self.assertEqual(topo.sim['S'].precedence, 7)
def test_register_is_true(self): sim1 = new_simulation(name="test_singleton") assert sim1 is topo.sim sid = id(topo.sim['S']) sim2 = copy.copy(topo.sim) assert sim2 is sim1 sim3 = copy.deepcopy(topo.sim) assert sim3 is sim1 self.assertEqual(id(sim3['S']), sid) topo.sim['S'].precedence = 111 p = pickle.dumps(topo.sim, 2) topo.sim['S'].precedence = 5 Simulation.register = False # to ensure the object's own register is being used sim4 = pickle.loads(p) Simulation.register = True assert sim4 is sim1 assert topo.sim['S'].precedence == 111, "%s" % topo.sim['S'].precedence
def test_register_is_true(self): sim1 = new_simulation(name="test_singleton") assert sim1 is topo.sim sid = id(topo.sim['S']) sim2 = copy.copy(topo.sim) assert sim2 is sim1 sim3 = copy.deepcopy(topo.sim) assert sim3 is sim1 self.assertEqual(id(sim3['S']),sid) topo.sim['S'].precedence=111 p = pickle.dumps(topo.sim,2) topo.sim['S'].precedence=5 Simulation.register=False # to ensure the object's own register is being used sim4 = pickle.loads(p) Simulation.register=True assert sim4 is sim1 assert topo.sim['S'].precedence==111,"%s"%topo.sim['S'].precedence