Пример #1
0
def test_can_add_components_to_entities(world):
    entity = world.create_entity()
    component = Component()
    assert not world.has_component(entity, Component)
    world.add_component(entity, component)
    assert world.has_component(entity, Component)
    assert world.get_component(entity, Component) is component
Пример #2
0
def test_can_pass_a_default_when_getting_a_component(world):
    entity = world.create_entity()
    assert world.get_component(entity, Component, missing="foo") == "foo"
Пример #3
0
def test_getting_a_non_existent_component_is_an_error(world):
    entity = world.create_entity()
    with pytest.raises(NoSuchComponentError):
        world.get_component(entity, Component)