selftest: Add --tmpdir to 'samba-tool gpo create' test
[metze/samba/wip.git] / source4 / scripting / python / samba / tests / samba_tool / base.py
index 628fd6c887629345c5598590a64cd6673fe45ba1..60ccaa543d7e1132c12253898f26c1dedaa3d9ff 100644 (file)
@@ -28,9 +28,8 @@ from samba.samdb import SamDB
 from cStringIO import StringIO
 from samba.netcmd.main import cmd_sambatool
 import samba.tests
-from testtools.matchers import Contains
 
-class SambaToolCmdTest(samba.tests.TestCase):
+class SambaToolCmdTest(samba.tests.TestCaseInTempDir):
 
     def getSamDB(self, *argv):
         """a convenience function to get a samdb instance so that we can query it"""
@@ -89,7 +88,7 @@ class SambaToolCmdTest(samba.tests.TestCase):
         self.assertIsNotNone(val, msg)
 
     def assertMatch(self, base, string, msg=""):
-        self.assertThat(base, Contains(string), msg)
+        self.assertTrue(string in base, msg)
 
     def randomName(self, count=8):
         """Create a random name, cap letters and numbers, and always starting with a letter"""
@@ -104,6 +103,12 @@ class SambaToolCmdTest(samba.tests.TestCase):
         name += ''.join(random.choice(string.ascii_uppercase + string.ascii_lowercase+ string.digits) for x in range(count - 3))
         return name
 
+    def randomXid(self):
+        # pick some hopefully unused, high UID/GID range to avoid interference
+        # from the system the test runs on
+        xid = random.randint(4711000, 4799000)
+        return xid
+
     def assertWithin(self, val1, val2, delta, msg=""):
         """Assert that val1 is within delta of val2, useful for time computations"""
         self.assertTrue(((val1 + delta) > val2) and ((val1 - delta) < val2), msg)