def test_multiple_state_application(monkeypatch): app = Application() app.register(StateMock) app.register(AnotherStateMock) assert len(app.states) == 2 # Ensure that Application._state hasn't changed assert isinstance(app.state, StateMock) app.state = AnotherStateMock.__name__ assert isinstance(app.state, AnotherStateMock) # Test Application.trigger_state called_with = [] def new_trigger(self, *args, **kwargs): called_with.extend([args, kwargs]) monkeypatch.setattr(StateMock, "trigger", new_trigger) app.trigger_state(StateMock.__name__, 10, test=20) assert isinstance(app.state, StateMock) assert called_with == [(10, ), {"test": 20}] # Test Application.trigger_reinit app.state.marker = "something" assert hasattr(app.state, "marker") is True app.trigger_reinit(StateMock.__name__) assert isinstance(app.state, StateMock) assert hasattr(app.state, "marker") is False assert pytest.raises(ValueError, lambda: setattr(app, "fps", "thirty"))
def test_application_loop(): app = Application() app.register(StateMock) # FIXME: test loop properly # assert app.start() is None app.register(AnotherStateMock) app.state = AnotherStateMock.__name__ # FIXME: test loop properly # assert app.start() is None assert app.stop() is None