1
0
mirror of https://github.com/samba-team/samba.git synced 2025-02-18 17:57:55 +03:00

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)
This commit is contained in:
Andreas Schneider 2023-01-24 09:18:46 +01:00 committed by Jule Anger
parent f6bbd277dc
commit a19e32ef2c

View File

@ -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()