@@ -0,0 +1,2103 @@
+import time%0Aimport unittest%0A%0Afrom xoinvader.application import Application%0A%0A%0Aclass StateMock(object):%0A    on_event = None%0A%0A    def __init__(self, owner):%0A        self.owner = owner%0A        self.one_loop_passed = False%0A%0A    def events(self):%0A        if StateMock.on_event:%0A            StateMock.on_event()%0A        time.sleep(0.5)%0A%0A    def update(self):%0A        time.sleep(0.5)%0A%0A    def render(self):%0A        time.sleep(0.5)%0A        if self.one_loop_passed:%0A            self.owner.stop()%0A        else:%0A            self.one_loop_passed = True%0A%0A%0Aclass AnotherStateMock(StateMock):%0A    pass%0A%0A%0Aclass TestApplication(unittest.TestCase):%0A    def test_application_properties(self):%0A        # Empty object%0A        app = Application()%0A        self.assertRaises(AttributeError, lambda: app.state)%0A        self.assertRaises(AttributeError, app.loop)%0A        self.assertIs(app.running, False)%0A%0A        # One element%0A        app.register_state(StateMock)%0A        self.assertEqual(len(app._states), 1)%0A        self.assertEqual(app.state, StateMock.__name__)%0A%0A        def set_state():%0A            app.state = %22test%22%0A        self.assertRaises(KeyError, set_state)%0A%0A        # Many elements%0A        app.register_state(AnotherStateMock)%0A        self.assertEqual(len(app._states), 2)%0A        # Ensure that Application._state hasn't changed%0A        self.assertEqual(app.state, StateMock.__name__)%0A%0A        app.state = AnotherStateMock.__name__%0A        self.assertEqual(app.state, AnotherStateMock.__name__)%0A%0A    def test_application_loop(self):%0A%0A        def check_running_is_true():%0A            self.assertIs(app.running, True)%0A%0A        app = Application()%0A        app._mspf = 16%0A        state_mock = StateMock%0A%0A        state_mock.on_events = check_running_is_true%0A        app.register_state(StateMock)%0A        self.assertIs(app.running, False)%0A        app.loop()%0A        self.assertIs(app.running, False)%0A%0A        #TODO: test slow loop execution%0A%0A    @unittest.skipUnless(hasattr(Application, %22apply_startup_args%22), %22Not implemented.%22)%0A    def test_application_startup_args(self):%0A        app = Application(%7B%22arg1%22, %22val1%22%7D)%0A

Add application tests.