From bbf21bf366ff0d248f9c06b1cff600f339b8655e Mon Sep 17 00:00:00 2001 From: Markus Lehtonen Date: Thu, 12 Dec 2013 11:14:06 +0200 Subject: ComponentTestBase: use regex matching in log checking Signed-off-by: Markus Lehtonen --- tests/component/__init__.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'tests') diff --git a/tests/component/__init__.py b/tests/component/__init__.py index 240b721..4ef2256 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""" -- cgit v1.2.3