summaryrefslogtreecommitdiff
path: root/python
diff options
context:
space:
mode:
authorDouglas Bagnall <douglas.bagnall@catalyst.net.nz>2018-02-09 14:29:43 +1300
committerAndrew Bartlett <abartlet@samba.org>2018-02-12 00:50:25 +0100
commit72a81529aa13ac34a6dc1b1cdc37d1329af48ffe (patch)
tree7a7b9e864a931b49fd70d6e2e3b7ae81dd369bcd /python
parent597e755328940fc964b861333b557b0650666b24 (diff)
downloadsamba-72a81529aa13ac34a6dc1b1cdc37d1329af48ffe.tar.gz
tests: SambaToolCmdTest.assertMatch() indicates what was asserted
Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Diffstat (limited to 'python')
-rw-r--r--python/samba/tests/samba_tool/base.py12
1 files changed, 11 insertions, 1 deletions
diff --git a/python/samba/tests/samba_tool/base.py b/python/samba/tests/samba_tool/base.py
index c57e9e94a1b..de257e3db09 100644
--- a/python/samba/tests/samba_tool/base.py
+++ b/python/samba/tests/samba_tool/base.py
@@ -29,6 +29,13 @@ from cStringIO import StringIO
from samba.netcmd.main import cmd_sambatool
import samba.tests
+
+def truncate_string(s, cutoff=100):
+ if len(s) < cutoff + 15:
+ return s
+ return s[:cutoff] + '[%d more characters]' % (len(s) - cutoff)
+
+
class SambaToolCmdTest(samba.tests.BlackboxTestCase):
def getSamDB(self, *argv):
@@ -88,7 +95,10 @@ class SambaToolCmdTest(samba.tests.BlackboxTestCase):
def assertCmdFail(self, val, msg=""):
self.assertIsNotNone(val, msg)
- def assertMatch(self, base, string, msg=""):
+ def assertMatch(self, base, string, msg=None):
+ if msg is None:
+ msg = "%r is not in %r" % (truncate_string(string),
+ truncate_string(base))
self.assertTrue(string in base, msg)
def randomName(self, count=8):