Files
chia-blockchain/tests/util/temp_file.py
T

13 lines
261 B
Python

import contextlib
import tempfile
from pathlib import Path
from typing import Iterator
@contextlib.contextmanager
def TempFile() -> Iterator[Path]:
path = Path(tempfile.NamedTemporaryFile().name)
yield path
if path.exists():
path.unlink()