repro.common.tempdir#
- class repro.common.tempdir.TemporaryDirectory(root=None, persist=False)#
Creates a temporary directory that works with a context manager (the python
withstatement). This class was created because the user is responsible for deleting the directory created bytempfile.mkdtemp. Instead, the context manager ensures the directory is deleted at the end.Example usage:
with TemporaryDirectory() as temp_dir: with open(temp_dir + '/file.txt') as out: ...
- Parameters
root (
str, optional (default =None)) – The root directory where the temporary directory should be created. IfNone, thetempfile.mkdtempdefault location is used.persist (
bool, optional (default = False)) – Indicates whether or not the directory should be persist on disk after the context closes.