def test_model_checkpoint_path(tmp_path, logger_version: Union[None, int, str], expected: str):
    """Test that "version_" prefix is only added when logger's version is an integer."""
    model = LogInTwoMethods()
    logger = TensorBoardLogger(tmp_path, version=logger_version)

    trainer = Trainer(default_root_dir=tmp_path, overfit_batches=0.2, max_epochs=2, logger=logger)
    trainer.fit(model)

    ckpt_version = Path(trainer.checkpoint_callback.dirpath).parent.name
    assert ckpt_version == expected
Test that "version_" prefix is only added when logger's version is an integer.
tests/tests_pytorch/checkpointing/test_model_checkpoint.py