def test_expand_home():
    """Test that the dirpath gets expanded if it contains `~`."""
    home_root = Path.home()

    checkpoint = ModelCheckpoint(dirpath="~/checkpoints")
    assert checkpoint.dirpath == str(home_root / "checkpoints")
    checkpoint = ModelCheckpoint(dirpath=Path("~/checkpoints"))
    assert checkpoint.dirpath == str(home_root / "checkpoints")

    # it is possible to have a folder with the name `~`
    checkpoint = ModelCheckpoint(dirpath="./~/checkpoints")
    assert checkpoint.dirpath == str(Path.cwd() / "~" / "checkpoints")
Test that the dirpath gets expanded if it contains `~`.
tests/tests_pytorch/checkpointing/test_model_checkpoint.py