diff options
author | Andreas Schneider <asn@samba.org> | 2023-01-24 09:18:46 +0100 |
---|---|---|
committer | Jule Anger <janger@samba.org> | 2023-02-10 10:52:15 +0000 |
commit | a19e32ef2cbf93657b4a84d0f238d68647bfe3ac (patch) | |
tree | abc511d701d43b76d7c550c54d3640f5a2cf0253 | |
parent | f6bbd277dcb05b1d4a92aa7ee2dd5b2a0ed2ecc8 (diff) | |
download | samba-a19e32ef2cbf93657b4a84d0f238d68647bfe3ac.tar.gz |
python:tests: Avoid exceptions in cleanup code if a test fails in smb3unix.py
BUG: https://bugzilla.samba.org/show_bug.cgi?id=15301
Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
(cherry picked from commit e6f0e4d53285177f7a60559394efeb5a78b6bd53)
-rw-r--r-- | python/samba/tests/smb3unix.py | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/python/samba/tests/smb3unix.py b/python/samba/tests/smb3unix.py index 3ad49af09fa..d8f9b7d5c33 100644 --- a/python/samba/tests/smb3unix.py +++ b/python/samba/tests/smb3unix.py @@ -189,8 +189,9 @@ class Smb3UnixTests(samba.tests.libsmb.LibsmbTests): 'SMB2_FIND_POSIX_INFORMATION failed to list contents') finally: - for fname in test_files: - self.delete_test_file(c, fname) + if len(test_files) > 0: + for fname in test_files: + self.delete_test_file(c, fname) self.disable_smb3unix() @@ -283,6 +284,7 @@ class Smb3UnixTests(samba.tests.libsmb.LibsmbTests): self.disable_smb3unix() def test_posix_perm_files(self): + test_files = {} try: self.enable_smb3unix() @@ -294,7 +296,6 @@ class Smb3UnixTests(samba.tests.libsmb.LibsmbTests): posix=True) self.assertTrue(c.have_posix()) - test_files = {} for perm in range(0o600, 0o7777+1): # Owner write permission is required or cleanup will fail, and # owner read is required to list the file if O_PATH is disabled @@ -332,8 +333,9 @@ class Smb3UnixTests(samba.tests.libsmb.LibsmbTests): (test_files[fname], found_files[fname])) finally: - for fname in test_files.keys(): - self.delete_test_file(c, '\\%s' % fname) + if len(test_files) > 0: + for fname in test_files.keys(): + self.delete_test_file(c, '\\%s' % fname) self.disable_smb3unix() |