Exemple #1
0
def test_on_shutdown_function():
    context = Context()
    context.init()

    callback_called = False

    def on_shutdown():
        nonlocal callback_called
        callback_called = True

    context.on_shutdown(on_shutdown)

    context.shutdown()

    assert callback_called
Exemple #2
0
def test_on_shutdown_method():
    context = Context()
    context.init()

    callback_called = False

    class SomeClass:

        def on_shutdown(self):
            nonlocal callback_called
            callback_called = True

    instance = SomeClass()
    context.on_shutdown(instance.on_shutdown)

    context.shutdown()

    assert callback_called