summaryrefslogtreecommitdiff
path: root/python/subunit
diff options
context:
space:
mode:
authorJonathan Lange <jml@mumak.net>2012-04-19 19:13:36 +0100
committerJonathan Lange <jml@mumak.net>2012-04-19 19:13:36 +0100
commit87338c132fb605881db065c20b9aa2f293946e8e (patch)
tree9123b3ee5b2ab92c76176f2bacd08295f50e5db6 /python/subunit
parentdcf88f6c47a42c791ddf257ee4f6050e943ba906 (diff)
downloadsubunit-git-87338c132fb605881db065c20b9aa2f293946e8e.tar.gz
don't rely on current_tags, implement it ourselves.
Diffstat (limited to 'python/subunit')
-rw-r--r--python/subunit/test_results.py17
-rw-r--r--python/subunit/tests/test_subunit_filter.py8
-rw-r--r--python/subunit/tests/test_test_results.py10
3 files changed, 16 insertions, 19 deletions
diff --git a/python/subunit/test_results.py b/python/subunit/test_results.py
index ce8f67a..b6e9be8 100644
--- a/python/subunit/test_results.py
+++ b/python/subunit/test_results.py
@@ -85,10 +85,6 @@ 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
@@ -315,6 +311,7 @@ class _PredicateFilter(TestResultDecorator):
self.decorated = TimeCollapsingDecorator(
TagCollapsingDecorator(self.decorated))
self._predicate = predicate
+ self._current_tags = set()
# The current test (for filtering tags)
self._current_test = None
# Has the current test been filtered (for outputting test tags)
@@ -326,7 +323,7 @@ class _PredicateFilter(TestResultDecorator):
# XXX: ExtendedToOriginalDecorator doesn't properly wrap current_tags.
# https://bugs.launchpad.net/testtools/+bug/978027
return self._predicate(
- test, outcome, error, details, self.current_tags)
+ test, outcome, error, details, self._current_tags)
def addError(self, test, err=None, details=None):
if (self.filter_predicate(test, 'error', err, details)):
@@ -387,7 +384,6 @@ class _PredicateFilter(TestResultDecorator):
correctly.
"""
if not self._current_test_filtered:
- # Tags to output for this test.
for method, args, kwargs in self._buffered_calls:
getattr(self.decorated, method)(*args, **kwargs)
self.decorated.stopTest(test)
@@ -395,6 +391,15 @@ class _PredicateFilter(TestResultDecorator):
self._current_test_filtered = None
self._buffered_calls = []
+ def tags(self, new_tags, gone_tags):
+ new_tags, gone_tags = set(new_tags), set(gone_tags)
+ self._current_tags.update(new_tags)
+ self._current_tags.difference_update(gone_tags)
+ if self._current_test is not None:
+ self._buffered_calls.append(('tags', [new_tags, gone_tags], {}))
+ else:
+ return super(_PredicateFilter, self).tags(new_tags, gone_tags)
+
def time(self, a_time):
if self._current_test is not None:
self._buffered_calls.append(('time', [a_time], {}))
diff --git a/python/subunit/tests/test_subunit_filter.py b/python/subunit/tests/test_subunit_filter.py
index d5f204a..35d4603 100644
--- a/python/subunit/tests/test_subunit_filter.py
+++ b/python/subunit/tests/test_subunit_filter.py
@@ -92,7 +92,6 @@ xfail todo
('startTest', test),
('addSuccess', test),
('stopTest', test),
- ('tags', set(['local']), set()),
],
result._events)
@@ -298,9 +297,12 @@ xfail todo
events = self.to_events(output)
foo = subunit.RemotedTestCase('foo')
self.assertEqual(
- [('startTest', foo),
+ [('tags', set(['a']), set()),
+ ('startTest', foo),
('addSuccess', foo),
- ('stopTest', foo)],
+ ('stopTest', foo),
+ ('tags', set(), set(['a'])),
+ ],
events)
diff --git a/python/subunit/tests/test_test_results.py b/python/subunit/tests/test_test_results.py
index 2bec7e3..6beb57a 100644
--- a/python/subunit/tests/test_test_results.py
+++ b/python/subunit/tests/test_test_results.py
@@ -56,16 +56,6 @@ 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):