From 074f9e1486613c6e4f6bbff9222a23ba6bdf3603 Mon Sep 17 00:00:00 2001 From: Douglas Bagnall Date: Fri, 28 May 2021 16:54:33 +1200 Subject: [PATCH] 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 --- python/samba/tests/samba_tool/dnscmd.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) 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() -- 2.47.3