def test_wrong_configure_optimizers(tmp_path):
    """Test that an error is thrown when no `configure_optimizers()` is defined."""
    trainer = Trainer(default_root_dir=tmp_path, max_epochs=1)

    with pytest.raises(MisconfigurationException, match=r"No `configure_optimizers\(\)` method defined."):
        model = BoringModel()
        model.configure_optimizers = None
        trainer.fit(model)
Test that an error is thrown when no `configure_optimizers()` is defined.
tests/tests_pytorch/trainer/test_config_validator.py