]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
pytest:samba-tool dns: more robust clean-up
authorDouglas Bagnall <douglas.bagnall@catalyst.net.nz>
Fri, 28 May 2021 04:54:33 +0000 (16:54 +1200)
committerDouglas Bagnall <dbagnall@samba.org>
Wed, 2 Jun 2021 03:56:36 +0000 (03:56 +0000)
If setUp() fails (and here we have a big .setUp), .tearDown is not run,
and that can leave the zone undeleted, breaking all the other tests who
expect to be able to recreate it.

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
python/samba/tests/samba_tool/dnscmd.py

index 0048e390ce589a60257dd65955bd35699c2bdfc0..5486ad4d05ffe7bd71193264c380031a5e17961a 100644 (file)
@@ -40,6 +40,7 @@ class DnsCmdTestCase(SambaToolCmdTest):
         self.testip = "192.168.0.193"
         self.testip2 = "192.168.0.194"
 
+        self.addCleanup(self.deleteZone)
         self.addZone()
 
         # Note: SOA types don't work (and shouldn't), as we only have one zone per DNS record.
@@ -115,10 +116,6 @@ class DnsCmdTestCase(SambaToolCmdTest):
                 "SRV": bad_srv
         }
 
-    def tearDown(self):
-        self.deleteZone()
-        super(DnsCmdTestCase, self).tearDown()
-
     def resetZone(self):
         self.deleteZone()
         self.addZone()