def test_fabric_call_lightning_module_hooks():
    """Test that `Fabric.call` can call hooks on the LightningModule."""

    class HookedModel(BoringModel):
        def on_train_start(self):
            pass

        def on_my_custom_hook(self, arg, kwarg=None):
            pass

    fabric = Fabric(accelerator="cpu", devices=1)
    module = Mock(wraps=HookedModel())

    _ = fabric.setup(module)
    _ = fabric.setup(module)  # shouldn't add module to callbacks a second time
    assert fabric._callbacks == [module]

    fabric.call("on_train_start")
    module.on_train_start.assert_called_once_with()

    fabric.call("on_my_custom_hook", 1, kwarg="test")
    module.on_my_custom_hook.assert_called_once_with(1, kwarg="test")
Test that `Fabric.call` can call hooks on the LightningModule.
tests/tests_pytorch/models/test_fabric_integration.py