def test_none_monitor_not_alternating(tmp_path):
    """Regression test for the case where the callback saved alternating `model.ckpt` and `model-v1.ckpt` files."""

    class ListDirModel(BoringModel):
        def on_train_epoch_start(self):
            if self.current_epoch > 0:
                assert os.listdir(tmp_path) == ["model.ckpt"]

    model = ListDirModel()
    model_checkpoint = ModelCheckpoint(dirpath=tmp_path, monitor=None, save_top_k=1, filename="model")
    trainer = Trainer(
        callbacks=model_checkpoint,
        limit_train_batches=1,
        limit_val_batches=0,
        max_epochs=3,
        enable_model_summary=False,
        enable_progress_bar=False,
        logger=False,
    )
    trainer.fit(model)
Regression test for the case where the callback saved alternating `model.ckpt` and `model-v1.ckpt` files.
tests/tests_pytorch/checkpointing/test_model_checkpoint.py