python/samba/tests: Adjust teardown so second run of tests succeeds
authorNoel Power <noel.power@suse.com>
Tue, 14 Aug 2018 10:43:44 +0000 (11:43 +0100)
committerAndrew Bartlett <abartlet@samba.org>
Mon, 3 Sep 2018 01:22:25 +0000 (03:22 +0200)
A second run of this test (e.g. with --extra-python) or even
an manual re-run and the cache is still there.
use of '--cache-ldb-initialize'  will fail and so with the test
Signed-off-by: Noel Power <noel.power@suse.com>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
python/samba/tests/samba_tool/user.py

index 5449db33a52729b21f9144d9762f542c7c28efa6..be090030afd15ed8eb83c4b7d50a81d5c63374e7 100644 (file)
@@ -29,6 +29,7 @@ from samba.ndr import ndr_unpack
 from samba.dcerpc import drsblobs
 from samba.compat import get_bytes
 from samba.compat import get_string
+from samba.tests import env_loadparm
 
 
 class UserCmdTestCase(SambaToolCmdTest):
@@ -66,6 +67,13 @@ class UserCmdTestCase(SambaToolCmdTest):
         for user in self.users:
             if self._find_user(user["name"]):
                 self.runsubcmd("user", "delete", user["name"])
+        lp = env_loadparm()
+        # second run of this test (e.g. with --extra-python)
+        # the cache is still there and '--cache-ldb-initialize'
+        # will fail
+        cachedb = lp.private_path("user-syncpasswords-cache.ldb")
+        if os.path.exists(cachedb):
+            os.remove(cachedb)
 
     def test_newuser(self):
         # try to add all the users again, this should fail