def test_on_load_checkpoint_missing_callbacks(tmp_path):
    """Test a warning appears when callbacks in the checkpoint don't match callbacks provided when resuming."""
    model = BoringModel()
    chk = ModelCheckpoint(dirpath=tmp_path, save_last=True)

    trainer = Trainer(default_root_dir=tmp_path, max_epochs=3, callbacks=[chk, CustomCallbackOnLoadCheckpoint()])
    trainer.fit(model)

    trainer = Trainer(default_root_dir=tmp_path, max_epochs=5)
    with pytest.warns(UserWarning, match="CustomCallbackOnLoadCheckpoint"):
        trainer.fit(model, ckpt_path=chk.last_model_path)
Test a warning appears when callbacks in the checkpoint don't match callbacks provided when resuming.
tests/tests_pytorch/trainer/test_trainer.py