summaryrefslogtreecommitdiff
path: root/python
diff options
context:
space:
mode:
authorJonathan Lange <jml@mumak.net>2012-04-10 14:26:44 +0100
committerJonathan Lange <jml@mumak.net>2012-04-10 14:26:44 +0100
commit8ff7d39c1e1e247d860053026d6fd0867379adb0 (patch)
tree683b7166b0075cfd6daa10e21429bfdfbfacb724 /python
parentbd5107a642a7b704661e492566e588e944669a25 (diff)
downloadsubunit-git-8ff7d39c1e1e247d860053026d6fd0867379adb0.tar.gz
Allow the predicate to filter tags.
Diffstat (limited to 'python')
-rw-r--r--python/subunit/test_results.py13
-rw-r--r--python/subunit/tests/test_test_results.py10
2 files changed, 22 insertions, 1 deletions
diff --git a/python/subunit/test_results.py b/python/subunit/test_results.py
index 92e0310..0c6fbd5 100644
--- a/python/subunit/test_results.py
+++ b/python/subunit/test_results.py
@@ -81,6 +81,10 @@ class TestResultDecorator(object):
return self.decorated.wasSuccessful()
@property
+ def current_tags(self):
+ return self.decorated.current_tags
+
+ @property
def shouldStop(self):
return self.decorated.shouldStop
@@ -301,7 +305,14 @@ class _PredicateFilter(TestResultDecorator):
self._buffered_calls = []
def filter_predicate(self, test, outcome, error, details):
- return self._predicate(test, outcome, error, details)
+ # XXX: ExtendedToOriginalDecorator doesn't properly wrap current_tags.
+ # https://bugs.launchpad.net/testtools/+bug/978027
+ tags = getattr(self.decorated, 'current_tags', frozenset())
+ # 0.0.7 and earlier did not support the 'tags' parameter.
+ try:
+ return self._predicate(test, outcome, error, details, tags)
+ except TypeError:
+ return self._predicate(test, outcome, error, details)
def addError(self, test, err=None, details=None):
if (self.filter_predicate(test, 'error', err, details)):
diff --git a/python/subunit/tests/test_test_results.py b/python/subunit/tests/test_test_results.py
index 6beb57a..2bec7e3 100644
--- a/python/subunit/tests/test_test_results.py
+++ b/python/subunit/tests/test_test_results.py
@@ -56,6 +56,16 @@ class AssertBeforeTestResult(LoggingDecorator):
super(AssertBeforeTestResult, self)._before_event()
+class TestTestResultDecorator(unittest.TestCase):
+
+ def test_current_tags(self):
+ result = ExtendedTestResult()
+ decorator = subunit.test_results.TestResultDecorator(result)
+ decorator.tags(set('foo'), set())
+ self.assertEqual(set('foo'), decorator.current_tags)
+ self.assertEqual(decorator.current_tags, result.current_tags)
+
+
class TimeCapturingResult(unittest.TestResult):
def __init__(self):