def test_scene_remove_queued_object(self): scene = Scene(None) obj = GameObject() scene.add_object(obj) scene.remove_object(obj) scene.setup_frame(1.0) self.assertEqual(0, len(scene.objects))
def test_remove_object(self): scene = Scene(None) objects = [GameObject() for x in range(0, 1000)] for obj in objects: scene.add_object(obj) scene.setup_frame(1.0) cut = len(objects)//2 for obj in objects[:cut]: scene.remove_object(obj) self.assertEqual(len(objects) - cut, len(scene.objects)) self.assertSetEqual(set(objects[cut:]), set(scene.objects.values()))
def test_removed_objects_are_cleared_on_frame_end(self): scene = Scene(None) objects = [GameObject() for x in range(0, 100)] for obj in objects: scene.add_object(obj) scene.setup_frame(1.0) scene.simulate_preframe() scene.simulate_postframe() scene.remove_object(objects[0]) scene.setup_frame(1.0) scene.simulate_preframe() scene.simulate_postframe() self.assertIsNone(objects[0].scene) self.assertIsNone(objects[0].id)
def test_remove_on_empty_exception(self): scene = Scene(None) with self.assertRaises(ValueError): scene.remove_object(GameObject())