summaryrefslogtreecommitdiff
path: root/python
diff options
context:
space:
mode:
authorDouglas Bagnall <douglas.bagnall@catalyst.net.nz>2018-02-11 11:59:40 +1300
committerAndrew Bartlett <abartlet@samba.org>2018-02-15 00:18:29 +0100
commit92ec01dcf080901eb4c208b208651ae03e77f538 (patch)
treea6473cd18792ac24efb758e1ff74f9bade1c98b6 /python
parent70a85c163ff7397075bf0cef8a483df4f33799b4 (diff)
downloadsamba-92ec01dcf080901eb4c208b208651ae03e77f538.tar.gz
python.subunit: add assertRegexpMatches for Python 2.6
This is used in python/samba/tests/samba_tool/provision_password_check.py 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/__init__.py11
1 files changed, 10 insertions, 1 deletions
diff --git a/python/samba/tests/__init__.py b/python/samba/tests/__init__.py
index c4d24fa913f..b6293dff757 100644
--- a/python/samba/tests/__init__.py
+++ b/python/samba/tests/__init__.py
@@ -31,9 +31,10 @@ import subprocess
import sys
import tempfile
import unittest
+import re
import samba.auth
import samba.dcerpc.base
-from samba.compat import PY3
+from samba.compat import PY3, text_type
if not PY3:
# Py2 only
from samba.samdb import SamDB
@@ -161,6 +162,14 @@ class TestCase(unittest.TestCase):
self._cleanups = getattr(self, "_cleanups", []) + [
(fn, args, kwargs)]
+ def assertRegexpMatches(self, text, regex, msg=None):
+ # PY3 note: Python 3 will never see this, but we use
+ # text_type for the benefit of linters.
+ if isinstance(regex, (str, text_type)):
+ regex = re.compile(regex)
+ if not regex.search(text):
+ self.fail(msg)
+
def _addSkip(self, result, reason):
addSkip = getattr(result, 'addSkip', None)
if addSkip is not None: