import atexit
import os
import shutil
import tempfile
if "WORLDGEN_TEST_TMP" not in os.environ:
_root = tempfile.mkdtemp(prefix="worldgen-tests-")
os.environ["WORLDGEN_TEST_TMP"] = os.environ["TMPDIR"] = tempfile.tempdir = _root
_pid = os.getpid()
atexit.register(lambda: os.getpid() == _pid and shutil.rmtree(_root, True))