diff options
author | Andreas Schneider <asn@samba.org> | 2023-02-08 11:16:12 +0100 |
---|---|---|
committer | Jule Anger <janger@samba.org> | 2023-02-24 08:56:14 +0000 |
commit | 8739c9c72ddb346642e4adf98b1fb8f4440cf288 (patch) | |
tree | af02841aa1adff0edaf246b506f7ceb536ef9d14 | |
parent | 9e8cc236bd3111b81289fe35187e6d8e5d843ea8 (diff) | |
download | samba-8739c9c72ddb346642e4adf98b1fb8f4440cf288.tar.gz |
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 <asn@samba.org>
Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
(cherry picked from commit 804fb07259b87e80993b1916935b626906e04580)
-rw-r--r-- | python/samba/tests/domain_backup.py | 5 |
1 files changed, 4 insertions, 1 deletions
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""" |