(replacement)
Monkey-patch tempfile.tempdir with replacement, ensuring it exists
Monkey-patch tempfile.tempdir with replacement, ensuring it exists
Monkey - patch tempfile . tempdir with replacement ensuring it exists
def override_temp(replacement):
    """
    Monkey-patch tempfile.tempdir with replacement, ensuring it exists
    """
    pkg_resources.py31compat.makedirs(replacement, exist_ok=True)

    saved = tempfile.tempdir

    tempfile.tempdir = replacement

    try:
        yield
    finally:
        tempfile.tempdir = saved
def override_temp ( replacement ) : pkg_resources . py31compat . makedirs ( replacement , exist_ok = True ) saved = tempfile . tempdir tempfile . tempdir = replacement try : yield finally : tempfile . tempdir = saved