def test_trainer_predict_no_return(tmp_path):
    """Test trainer.predict warns when nothing is returned."""

    class CustomBoringModel(BoringModel):
        def predict_step(self, batch, batch_idx, dataloader_idx=0):
            if (batch_idx + 1) % 2 == 0:
                return None

            return super().predict_step(batch, batch_idx, dataloader_idx)

    with pytest.warns(UserWarning, match="predict returned None"):
        predict(tmp_path, model=CustomBoringModel(), use_callbacks=False)
Test trainer.predict warns when nothing is returned.
tests/tests_pytorch/trainer/test_trainer.py