def test_eq(self): from bGrease import Entity world = TestWorld() e1 = Entity(world) e2 = Entity(world) self.assertNotEqual(e1, e2) e2.entity_id = e1.entity_id self.assertEqual(e1, e2) otherworld = TestWorld() e3 = Entity(otherworld) self.assertNotEqual(e1, e3) self.assertNotEqual(e2, e3) e3.entity_id = e1.entity_id self.assertNotEqual(e1, e3) self.assertNotEqual(e2, e3)
def test_delete_exists(self): from bGrease import Entity world = TestWorld() self.assertEqual(world.entities, set()) entity1 = Entity(world) entity2 = Entity(world) self.assertEqual(world.entities, set([entity1, entity2])) self.assertTrue(entity1.exists) self.assertTrue(entity2.exists) entity1.delete() self.assertEqual(world.entities, set([entity2])) self.assertFalse(entity1.exists) self.assertTrue(entity2.exists) entity2.delete() self.assertEqual(world.entities, set()) self.assertFalse(entity1.exists) self.assertFalse(entity2.exists)
def __init__(self, world, identifier): Entity.__init__(self, world) if not General.registered_as: General.register() getattr(self, General.registered_as).identifier = identifier