def test_search_game_object_by_tags(self): '''Search game objects by tags''' scene = retro.Scene('test_scene') game_object1 = retro.GameObject() game_object2 = retro.GameObject(tags=[TAG1]) game_object3 = retro.GameObject(tags=[TAG1, TAG2]) scene.add_game_object(game_object1) scene.add_game_object(game_object2) scene.add_game_object(game_object3) assert game_object1 not in scene.game_objects_tagged_as(TAG1) assert game_object1 not in scene.game_objects_tagged_as(TAG2) assert game_object2 in scene.game_objects_tagged_as(TAG1) assert game_object2 not in scene.game_objects_tagged_as(TAG2) assert game_object3 in scene.game_objects_tagged_as(TAG1) assert game_object3 in scene.game_objects_tagged_as(TAG2)
def test_remove_game_object(self): '''Test remove GameObject() from a scene''' scene = retro.Scene('test_scene') game_object = retro.GameObject() scene.add_game_object(game_object) scene.remove_game_object(game_object) assert len(scene.game_objects) == 0
def test_creation(self): '''Create new GameObject() and check its initial state''' go = retro.GameObject() assert isinstance(go, retro.GameObject) assert go.scene is None assert not go.is_running assert go.is_alive assert len(go.tags) == 0
def test_add_game_object(self): '''Add GameObject() to a scene''' scene = retro.Scene('test_scene') game_object = retro.GameObject() scene.add_game_object(game_object) assert len(scene.game_objects) == 1 assert game_object is scene.game_object(game_object.id) assert game_object.scene is scene
def test_garbage_collector(self): '''Test if Scene() removes dead GameObject() objects''' scene = retro.Scene('test_scene') game_object = retro.GameObject() scene.add_game_object(game_object) assert game_object in scene.game_objects game_object.kill() scene.update() assert game_object not in scene.game_objects
def test_tagging2(self): '''Add and remove several tags in a GameObject()''' go = retro.GameObject() go.add_tag(TAG1) go.add_tag(TAG2) assert go.is_tagged_as(TAG1) and go.is_tagged_as(TAG2) go.remove_tag(TAG1) assert not go.is_tagged_as(TAG1) assert go.is_tagged_as(TAG2)
def test_creation_with_tags(self): '''Create new GameObject() with initial tags''' go = retro.GameObject(tags=[TAG1]) assert isinstance(go, retro.GameObject) assert go.scene is None assert not go.is_running assert go.is_alive assert TAG1 in go.tags assert go.is_tagged_as(TAG1)
def test_remove_unknown_game_object(self): '''Remove GameObject() not added to a scene''' scene = retro.Scene('test_scene') game_object = retro.GameObject() with pytest.raises(KeyError): scene.remove_game_object(game_object)
def test_tagging3(self): '''Remove unknown tags in a GameObject()''' go = retro.GameObject() assert not go.is_tagged_as(TAG1) with pytest.raises(KeyError): go.remove_tag(TAG1)
def test_tagging1(self): '''Add tag in a GameObject()''' go = retro.GameObject() go.add_tag(TAG1) assert TAG1 in go.tags assert go.is_tagged_as(TAG1)
def test_killing(self): '''Kill a GameObject() and check its state''' go = retro.GameObject() go.kill() assert not go.is_alive assert not go.is_running
def test_starting(self): '''Start a GameObject() and check its state''' go = retro.GameObject() go.start() assert go.is_running assert go.is_alive