nanoutils.testing_utils¶
Utility functions related to unit-testing.
Index¶
A |
|
|
A decorater which deletes the specified files and/or directories after calling the deocrated function. |
API¶
- exception nanoutils.FileNotFoundWarning[source]¶
A
ResourceWarning
subclass for when a file or directory is requested but doesn’t exist.
- @nanoutils.delete_finally(*paths, prefix=None, warn=True)[source]¶
A decorater which deletes the specified files and/or directories after calling the deocrated function.
Examples
>>> import os >>> from nanoutils import delete_finally >>> file1 = 'file1.txt' >>> dir1 = 'dir1/' >>> os.path.isfile(file1) and os.path.isdir(dir1) True >>> @delete_finally(file1, dir1) ... def func(): ... pass >>> func() >>> os.path.isfile(file1) or os.path.isdir(dir1) False
- Parameters:
*paths (
str
,bytes
oros.PathLike
) – Path-like objects with the names of to-be deleted files and/or directories.prefix (
str
,bytes
oros.PathLike
, optional) – The directory where all user specified paths are located. IfNone
, asume the files/directories are either absolute or located in the current working directory.warn (
bool
) – IfTrue
issue aFileNotFoundWarning
if a to-be deleted file or directory cannot be found.