def test_skip_training_step_not_allowed(world_size, tmp_path):
    """Test that skipping the training_step in distributed training is not allowed."""

    class TestModel(BoringModel):
        def training_step(self, batch, batch_idx):
            return None

    model = TestModel()
    trainer = Trainer(
        default_root_dir=tmp_path,
        max_steps=1,
        barebones=True,
    )
    trainer.strategy.world_size = world_size  # mock world size without launching processes
    error_context = (
        pytest.raises(RuntimeError, match="Skipping the `training_step` .* is not supported")
        if world_size > 1
        else nullcontext()
    )
    with error_context:
        trainer.fit(model)
Test that skipping the training_step in distributed training is not allowed.
tests/tests_pytorch/loops/optimization/test_automatic_loop.py