[lang-ref] ( temp_directory ) ( python )

def test_temp_directory():
    # tempfile.TemporaryDirectory
    with tempfile.TemporaryDirectory() as d:
        assert type(d) is str
        assert d.startswith('/var/')
def test_temp_directory_alternative():
    # pathlib.Path(d) for path operations
    with tempfile.TemporaryDirectory() as d:
        p = Path(d)
        assert p.is_dir()
        assert str(p).startswith('/var/')