xdoctest.utils.util_path module¶
Utilities related to filesystem paths
- class xdoctest.utils.util_path.TempDir(persist=False)[source]¶
Bases:
object
Context for creating and cleaning up temporary files. Used in testing.
Example
>>> with TempDir() as self: >>> dpath = self.dpath >>> assert exists(dpath) >>> assert not exists(dpath)
Example
>>> self = TempDir() >>> dpath = self.ensure() >>> assert exists(dpath) >>> self.cleanup() >>> assert not exists(dpath)
- xdoctest.utils.util_path.ensuredir(dpath, mode=1023)[source]¶
Ensures that directory will exist. creates new dir with sticky bits by default
- Parameters:
dpath (str) – dir to ensure. Can also be a tuple to send to join
mode (int) – octal mode of directory (default 0o1777)
- Returns:
path - the ensured directory
- Return type: