def test_Entity_world(self): world = World() world2 = World() ent1 = Entity(world) ent2 = Entity(world2) assert ent1.world == world assert ent1.world != world2 assert ent2.world == world2 assert ent2.world != world assert ent1.world != ent2.world
def test_Entity_world(self): world = World() world2 = World() ent1 = Entity(world) ent2 = Entity(world2) self.assertEqual(ent1.world, world) self.assertNotEqual(ent1.world, world2) self.assertEqual(ent2.world, world2) self.assertNotEqual(ent2.world, world) self.assertNotEqual(ent1.world, ent2.world)
def test_World_delete_entities(self): w = World() e1 = Entity(w) e2 = Entity(w) assert len(w.entities) == 2 w.delete_entities((e1, e2)) assert len(w.entities) == 0 # The next should have no effect w.delete_entities((e1, e2))
def test_World_delete_entities(self): w = World() e1 = Entity(w) e2 = Entity(w) self.assertEqual(len(w.entities), 2) w.delete_entities((e1, e2)) self.assertEqual(len(w.entities), 0) # The next should have no effect w.delete_entities((e1, e2))
def test_Entity(self): world = World() world.add_system(PositionSystem()) e = Entity(world) e2 = Entity(world) assert isinstance(e, Entity) assert isinstance(e2, Entity) assert e != e2 p = PositionEntity(world) assert isinstance(p, PositionEntity) assert isinstance(p, Entity)
def test_Entity(self): world = World() world.add_system(PositionSystem()) e = Entity(world) e2 = Entity(world) self.assertIsInstance(e, Entity) self.assertIsInstance(e2, Entity) self.assertNotEqual(e, e2) p = PositionEntity(world) self.assertIsInstance(p, PositionEntity) self.assertIsInstance(p, Entity)
def test_World_delete(self): w = World() e1 = Entity(w) e2 = Entity(w) assert len(w.entities) == 2 w.delete(e1) assert len(w.entities) == 1 w.delete(e2) assert len(w.entities) == 0 # The next two should have no effect w.delete(e1) w.delete(e2)
def test_World_delete(self): w = World() e1 = Entity(w) e2 = Entity(w) self.assertEqual(len(w.entities), 2) w.delete(e1) self.assertEqual(len(w.entities), 1) w.delete(e2) self.assertEqual(len(w.entities), 0) # The next two should have no effect w.delete(e1) w.delete(e2)
def test_World_entities(self): w = World() assert len(w.entities) == 0 for x in range(100): Entity(w) assert len(w.entities) == 100
def test_World_entities(self): w = World() self.assertEqual(len(w.entities), 0) for x in range(100): Entity(w) self.assertEqual(len(w.entities), 100)
def test_World_add_remove_system(self): world = World() assert isinstance(world, World) class SimpleSystem(object): def __init__(self): self.componenttypes = (Position, ) def process(self, world, components): pass for method in (world.add_system, world.remove_system): for val in (None, "Test", Position, Entity(world)): with pytest.raises(ValueError): method(val) psystem = SimpleSystem() world.add_system(psystem) assert len(world.systems) != 0 assert psystem in world.systems world.remove_system(psystem) assert len(world.systems) == 0 assert psystem not in world.systems psystem = PositionSystem() world.add_system(psystem) assert len(world.systems) != 0 assert psystem in world.systems entity = PositionEntity(world) assert isinstance(entity.position, Position) world.remove_system(psystem) assert len(world.systems) == 0 assert psystem not in world.systems # The data must stay intact in the world, even if the processing # system has been removed. assert isinstance(entity.position, Position)
def test_Entity_delete(self): w = World() e1 = Entity(w) e2 = Entity(w) assert len(w.entities) == 2 e1.delete() assert len(w.entities) == 1 e2.delete() assert len(w.entities) == 0 # The next two should have no effect e1.delete() e2.delete()
def test_Entity_id(self): world = World() ent1 = Entity(world) ent2 = Entity(world) assert ent1.id != ent2.id
def test_Entity_delete(self): w = World() e1 = Entity(w) e2 = Entity(w) self.assertEqual(len(w.entities), 2) e1.delete() self.assertEqual(len(w.entities), 1) e2.delete() self.assertEqual(len(w.entities), 0) # The next two should have no effect e1.delete() e2.delete()
def test_Entity_id(self): world = World() ent1 = Entity(world) ent2 = Entity(world) self.assertNotEqual(ent1.id, ent2.id)