diff options
Diffstat (limited to 'testing/framework/TestCmd.py')
-rw-r--r-- | testing/framework/TestCmd.py | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/testing/framework/TestCmd.py b/testing/framework/TestCmd.py index c207aa7e3..98094c875 100644 --- a/testing/framework/TestCmd.py +++ b/testing/framework/TestCmd.py @@ -1872,6 +1872,31 @@ class TestCmd: file = self.canonicalize(file) os.unlink(file) + def unlink_files(self, dirpath, files): + """Unlinks a list of file names from the specified directory. + + The directory path may be a list, in which case the elements are + concatenated with the os.path.join() method. + + A file name may be a list, in which case the elements are + concatenated with the os.path.join() method. + + The directory path and file name are concatenated with the + os.path.join() method. The resulting file path is assumed to be + under the temporary working directory unless it is an absolute path + name. An attempt to unlink the resulting file is made only when the + file exists otherwise the file path is ignored. + """ + if is_List(dirpath): + dirpath = os.path.join(*dirpath) + for file in files: + if is_List(file): + file = os.path.join(*file) + filepath = os.path.join(dirpath, file) + filepath = self.canonicalize(filepath) + if os.path.exists(filepath): + self.unlink(filepath) + def verbose_set(self, verbose) -> None: """Sets the verbose level.""" self.verbose = verbose |