diff options
| author | Robert Collins <robertc@robertcollins.net> | 2012-05-07 14:51:19 +1200 |
|---|---|---|
| committer | Robert Collins <robertc@robertcollins.net> | 2012-05-07 14:51:19 +1200 |
| commit | 9948b3e3638c143937f5acf9a1f375df25203f95 (patch) | |
| tree | 46fcbf850a84fc23db9814e90fc79451a78a2de6 /testtools/tests/test_testresult.py | |
| parent | 61eae6bfe6094b0ddfc630e1ea213dde8ca43295 (diff) | |
| download | testtools-9948b3e3638c143937f5acf9a1f375df25203f95.tar.gz | |
``ThreadsafeForwardingResult`` now forwards global tags as test-local tags,
making reasoning about the correctness of the multiplexed stream simpler.
This preserves the semantic value (what tags apply to a given test) while
consuming less stream size (as no negative-tag statement is needed).
(Robert Collins, Gary Poster, #986434)
Diffstat (limited to 'testtools/tests/test_testresult.py')
| -rw-r--r-- | testtools/tests/test_testresult.py | 21 |
1 files changed, 11 insertions, 10 deletions
diff --git a/testtools/tests/test_testresult.py b/testtools/tests/test_testresult.py index 330c18a..b6cafd1 100644 --- a/testtools/tests/test_testresult.py +++ b/testtools/tests/test_testresult.py @@ -799,8 +799,9 @@ class TestThreadSafeForwardingResult(TestCase): def test_global_tags_simple(self): # Tags specified outside of a test result are global. When a test's # results are finally forwarded, we send through these global tags - # *as* global tags, and also send a tags command at the end of the - # test that undoes it. + # *as* test specific tags, because as a multiplexer there should be no + # way for a global tag on an input stream to affect tests from other + # streams - we can just always issue test local tags. [result], events = self.make_results(1) result.tags(set(['foo']), set()) result.time(1) @@ -809,19 +810,20 @@ class TestThreadSafeForwardingResult(TestCase): result.addSuccess(self) self.assertEqual( [('time', 1), - ('tags', set(['foo']), set()), ('startTest', self), ('time', 2), + ('tags', set(['foo']), set()), ('addSuccess', self), ('stopTest', self), - ('tags', set(), set(['foo'])), ], events) def test_global_tags_complex(self): - # Multiple calls to tags() in a global context are merged together. - # Strictly speaking they could also be forwarded as multiple tags() - # calls. The key thing is that they are not sent until the test is - # done. + # Multiple calls to tags() in a global context are buffered until the + # next test completes and are issued as part of of the test context, + # because they cannot be issued until the output result is locked. + # The sample data shows them being merged together, this is, strictly + # speaking incidental - they could be issued separately (in-order) and + # still be legitimate. [result], events = self.make_results(1) result.tags(set(['foo', 'bar']), set(['baz', 'qux'])) result.tags(set(['cat', 'qux']), set(['bar', 'dog'])) @@ -831,12 +833,11 @@ class TestThreadSafeForwardingResult(TestCase): result.addSuccess(self) self.assertEqual( [('time', 1), - ('tags', set(['cat', 'foo', 'qux']), set(['dog', 'bar', 'baz'])), ('startTest', self), ('time', 2), + ('tags', set(['cat', 'foo', 'qux']), set(['dog', 'bar', 'baz'])), ('addSuccess', self), ('stopTest', self), - ('tags', set(['dog', 'bar', 'baz']), set(['cat', 'foo', 'qux'])), ], events) def test_local_tags(self): |
