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
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