]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
python:tests: Avoid exceptions in cleanup code if a test fails in smb3unix.py
authorAndreas Schneider <asn@samba.org>
Tue, 24 Jan 2023 08:18:46 +0000 (09:18 +0100)
committerAndreas Schneider <asn@cryptomilk.org>
Thu, 26 Jan 2023 12:15:33 +0000 (12:15 +0000)
Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
python/samba/tests/smb3unix.py

index 3ad49af09fabc85493323da769162d8776ab5e4c..d8f9b7d5c338f30554d2733d8de3a1861964799c 100644 (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()