From: Andreas Schneider Date: Wed, 8 Feb 2023 10:16:12 +0000 (+0100) Subject: python:tests: Fix domain_backup test with Python 3.11 X-Git-Tag: talloc-2.4.1~1597 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=804fb07259b87e80993b1916935b626906e04580;p=thirdparty%2Fsamba.git python:tests: Fix domain_backup test with Python 3.11 Traceback (most recent call last): File "bin/python/samba/tests/domain_backup.py", line 615, in test_backup_restore_with_conf self._test_backup_restore_with_conf() File "bin/python/samba/tests/domain_backup.py", line 244, in _test_backup_restore_with_conf self.restore_backup(backup_file, ["--configfile=" + smbconf]) File "bin/python/samba/tests/domain_backup.py", line 421, in restore_backup self.run_cmd(args) File "bin/python/samba/tests/domain_backup.py", line 384, in run_cmd self.cleanup_tempdir() File "bin/python/samba/tests/domain_backup.py", line 370, in cleanup_tempdir shutil.rmtree(filepath) File "/usr/lib64/python3.11/shutil.py", line 732, in rmtree _rmtree_safe_fd(fd, path, onerror) File "/usr/lib64/python3.11/shutil.py", line 635, in _rmtree_safe_fd onerror(os.scandir, path, sys.exc_info()) File "/usr/lib64/python3.11/shutil.py", line 631, in _rmtree_safe_fd with os.scandir(topfd) as scandir_it: ^^^^^^^^^^^^^^^^^ NotADirectoryError: [Errno 20] Not a directory: 'st/tmp/tmp7usvex3t/samba-backup-2023-02-08T10-13-18.461113.tar.bz2' BUG: https://bugzilla.samba.org/show_bug.cgi?id=15308 Signed-off-by: Andreas Schneider Reviewed-by: Douglas Bagnall Reviewed-by: Andrew Bartlett --- diff --git a/python/samba/tests/domain_backup.py b/python/samba/tests/domain_backup.py index b890a1030b7..2feef28bcb4 100644 --- a/python/samba/tests/domain_backup.py +++ b/python/samba/tests/domain_backup.py @@ -367,7 +367,10 @@ class DomainBackupBase(BlackboxTestCase): def cleanup_tempdir(self): for filename in os.listdir(self.tempdir): filepath = os.path.join(self.tempdir, filename) - shutil.rmtree(filepath) + if os.path.isfile(filepath): + os.remove(filepath) + elif os.path.isdir(filepath): + shutil.rmtree(filepath) def run_cmd(self, args): """Executes a samba-tool backup/restore command"""