def test_run_already_handled_event(self, app_context: ApplicationContext): """Tests that you can't run the same types of callbacks twice.""" yield from app_context.run_callbacks(ContextEventType.started) with pytest.raises(ValueError) as exc: yield from app_context.run_callbacks(ContextEventType.started) assert str(exc.value) == 'the started callbacks for this context have already been run'
def test_add_already_handled_event(self, app_context: ApplicationContext): """Tests that you can't add a callback to an event that's already been handled.""" yield from app_context.run_callbacks(ContextEventType.started) exc = pytest.raises(ValueError, app_context.add_callback, ContextEventType.started, lambda ctx: None) assert str(exc.value) == 'cannot add started callbacks to this context any more'