From: Douglas Bagnall Date: Fri, 28 May 2021 04:54:33 +0000 (+1200) Subject: pytest:samba-tool dns: more robust clean-up X-Git-Tag: tevent-0.11.0~696 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=074f9e1486613c6e4f6bbff9222a23ba6bdf3603;p=thirdparty%2Fsamba.git pytest:samba-tool dns: more robust clean-up 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 Reviewed-by: Andrew Bartlett --- diff --git a/python/samba/tests/samba_tool/dnscmd.py b/python/samba/tests/samba_tool/dnscmd.py index 0048e390ce5..5486ad4d05f 100644 --- a/python/samba/tests/samba_tool/dnscmd.py +++ b/python/samba/tests/samba_tool/dnscmd.py @@ -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()