aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests
diff options
context:
space:
mode:
authorMarkus Lehtonen <markus.lehtonen@linux.intel.com>2013-12-12 11:14:06 +0200
committerGuido Günther <agx@sigxcpu.org>2014-03-27 20:55:53 +0100
commitbbf21bf366ff0d248f9c06b1cff600f339b8655e (patch)
tree7cce84b294a3e77fe8ee5d47c16d74921e8fbce1 /tests
parent77743757e6aa619b57be4431daa46903c4da9ccd (diff)
ComponentTestBase: use regex matching in log checking
Signed-off-by: Markus Lehtonen <markus.lehtonen@linux.intel.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/component/__init__.py7
1 files changed, 4 insertions, 3 deletions
diff --git a/tests/component/__init__.py b/tests/component/__init__.py
index 240b721d..4ef22563 100644
--- a/tests/component/__init__.py
+++ b/tests/component/__init__.py
@@ -21,6 +21,7 @@ Module for testing individual command line tools of the git-buildpackage suite
"""
import os
+import re
import shutil
import tempfile
from StringIO import StringIO
@@ -165,13 +166,13 @@ class ComponentTestBase(object):
self._log.seek(0)
return self._log.readlines()
- def _check_log(self, linenum, string):
+ def _check_log(self, linenum, regex):
"""Check that the specified line on log matches expectations"""
if self._log is None:
raise Exception("BUG in unittests: no log captured!")
output = self._get_log()[linenum].strip()
- ok_(output.startswith(string), ("Expected: '%s...' Got: '%s'" %
- (string, output)))
+ ok_(re.match(regex, output),
+ "Log entry '%s' doesn't match '%s'" % (output, regex))
def _clear_log(self):
"""Clear the mock strerr"""