summaryrefslogtreecommitdiff
path: root/tests/compare.py
diff options
context:
space:
mode:
Diffstat (limited to 'tests/compare.py')
-rw-r--r--tests/compare.py23
1 files changed, 15 insertions, 8 deletions
diff --git a/tests/compare.py b/tests/compare.py
index cdbcc5d..7927467 100644
--- a/tests/compare.py
+++ b/tests/compare.py
@@ -1,7 +1,8 @@
#!/usr/bin/env python
+# -*- coding: utf-8 -*-
#
# compare.py -- High-level tests for dtrx.
-# Copyright (c) 2006, 2007, 2008 Brett Smith <brettcsmith@brettcsmith.org>.
+# Copyright © 2006-2009 Brett Smith <brettcsmith@brettcsmith.org>.
#
# This program is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by the
@@ -54,8 +55,13 @@ class ExtractorTest(object):
setattr(self, 'options', kwargs.get('options', '-n').split())
setattr(self, 'filenames', kwargs.get('filenames', '').split())
for key in ('directory', 'prerun', 'posttest', 'baseline', 'error',
- 'grep', 'antigrep', 'input', 'output', 'cleanup'):
+ 'input', 'output', 'cleanup'):
setattr(self, key, kwargs.get(key, None))
+ for key in ('grep', 'antigrep'):
+ value = kwargs.get(key, [])
+ if isinstance(value, str):
+ value = [value]
+ setattr(self, key, value)
def get_results(self, commands, stdin=None):
print >>output_buffer, "Output from %s:" % (' '.join(commands),)
@@ -165,12 +171,13 @@ class ExtractorTest(object):
return None
def grep_output(self, output):
- if self.grep and (not re.search(self.grep.replace(' ', '\\s+'),
- output, re.MULTILINE)):
- return "output did not match %s" % (self.grep)
- elif self.antigrep and re.search(self.antigrep.replace(' ', '\\s+'),
- output, re.MULTILINE):
- return "output matched antigrep %s" % (self.antigrep)
+ for pattern in self.grep:
+ if not re.search(pattern.replace(' ', '\\s+'), output,
+ re.MULTILINE):
+ return "output did not match %s" % (pattern)
+ for pattern in self.antigrep:
+ if re.search(pattern.replace(' ', '\\s+'), output, re.MULTILINE):
+ return "output matched antigrep %s" % (self.antigrep)
return None
def check_output(self, output):