def test_simple_destroy(self): root = GameObject(None) weak = ref(root) root.destroy() del root gc.collect() self.assertIsNone(weak()) self.assertFalse(game_objects)
def test_child_destroy(self): root = GameObject(None) child = GameObject(root) weak = ref(child) child.destroy() del child gc.collect() self.assertIsNone(weak()) self.assertSetEqual(root.children, set()) self.assertEqual(len(game_objects), 1)
def test_parent_destroy(self): root = GameObject(None) child = GameObject(root) weak_root = ref(root) weak_child = ref(child) root.destroy() del root del child gc.collect() self.assertIsNone(weak_root()) self.assertIsNone(weak_child()) self.assertFalse(game_objects)
def test_transform_create(self): root = GameObject(None) child = GameObject(root) self.assertEqual(len(game_objects), 2) root.x = 5 self.assertEqual(len(game_objects), 3) child.x = 5 self.assertEqual(len(game_objects), 4) root.destroy()