def test_overfit_basic(tmp_path, overfit_batches):
    """Tests that only training_step can be used when overfitting."""
    model = BoringModel()
    model.validation_step = None
    total_train_samples = len(BoringModel().train_dataloader())

    trainer = Trainer(
        default_root_dir=tmp_path, max_epochs=1, overfit_batches=overfit_batches, enable_model_summary=False
    )
    trainer.fit(model)

    assert trainer.num_val_batches == []
    assert trainer.num_training_batches == int(
        overfit_batches * (1 if isinstance(overfit_batches, int) else total_train_samples)
    )
Tests that only training_step can be used when overfitting.
tests/tests_pytorch/trainer/flags/test_overfit_batches.py