def test_simple_profiler_with_nonexisting_dirpath(tmp_path):
    """Ensure the profiler creates non-existing dirpath."""
    nonexisting_tmp_path = tmp_path / "nonexisting"

    profiler = SimpleProfiler(dirpath=nonexisting_tmp_path, filename="profiler")

    model = BoringModel()
    trainer = Trainer(
        default_root_dir=tmp_path, max_epochs=1, limit_train_batches=1, limit_val_batches=1, profiler=profiler
    )
    trainer.fit(model)

    assert nonexisting_tmp_path.exists()
    assert (nonexisting_tmp_path / "fit-profiler.txt").exists()
Ensure the profiler creates non-existing dirpath.
tests/tests_pytorch/profilers/test_profiler.py