예제 #1
0
def test_kutana_shutdown():
    for exception in [Exception, KeyboardInterrupt]:
        app = Kutana()

        _shutdown = app._shutdown

        async def checker():
            checker._called += 1
            await _shutdown()

        checker._called = 0

        app._main_loop = MagicMock(side_effect=exception)
        app._shutdown = checker
        app.run()

        assert checker._called == 1
예제 #2
0
def test_kutana_shutdown():
    app = Kutana()

    async def trigger():
        raise KeyboardInterrupt

    _shutdown = app._shutdown
    async def checker():
        checker._called = True
        await _shutdown()
    checker._called = False

    app._main_loop = trigger
    app._shutdown = checker
    app.run()

    assert checker._called == True