import scratchdir with scratchdir.ScratchDir() as sd: tmp = sd.named(suffix='.txt', prefix='logfile-', delete=False) print(tmp.name)
def scratch_dir(tmpdir): """ Fixture that yields a :class:`~scratchdir.ScratchDir` instance with a root directory that is unique to each test invocation. """ return scratchdir.ScratchDir(root=tmpdir.strpath)
import scratchdir with scratchdir.ScratchDir(prefix='grandparent-') as grandparent: print(grandparent.wd) with grandparent.child(prefix='parent-') as parent: print(parent.wd) with parent.child(prefix='child-') as child: print(child.wd)
import scratchdir sd = scratchdir.ScratchDir() sd.setup() print(sd.wd) sd.teardown()