Skip to content

Confused by the workflow of KivyUnitTest #6

@pakal

Description

@pakal

Hello,

Thanks for this module (I'm having troubles finding nice ways to test Kiby, now that InteractiveLauncher is deprecated). But I don't understand the principles of KivyUnitTest.

From my understanding, in a GUI engine like Kivy, everything runs synchronously in a single main thread.

So in your readme example excerpt below, run_test(), having been schedule on the Clock, should run entirely as a scheduled callback, before any other event can be processed by the main loop.

Thus, if it ends with app.stop() , the application will stop immediately, before any other scheduled event (like pause()) has a chance to be executed. So it shouldn't be possible to test, with this system, long operations with frame refreshes and user interactions.

What am I missing ? There is no "preemptive interrupts" or "greenlets" in Kivy here, is there ? Interrupting the python function runtest() right in the middle to play other events would be fragile, wouldn't it?

class Test(unittest.TestCase):
    def pause(*args):
        time.sleep(0.000001)

    def run_test(self, app, *args):
        Clock.schedule_interval(self.pause, 0.000001)
        # Do stuffs
        app.stop()

def test_example(self):
        app = My()
        p = partial(self.run_test, app)
        Clock.schedule_once(p, 0.000001)
        app.run()

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions