~barry/testtools/py3

« back to all changes in this revision

Viewing changes to testtools/tests/test_testresult.py

  • Committer: Jonathan Lange
  • Date: 2012-04-19 12:21:05 UTC
  • mfrom: (253.1.2 tag-leakage)
  • Revision ID: jml@mumak.net-20120419122105-tq28ee16neo641sv
Don't leak tags.

Show diffs side-by-side

added added

removed removed

Lines of Context:
17
17
from testtools import (
18
18
    ExtendedToOriginalDecorator,
19
19
    MultiTestResult,
 
20
    PlaceHolder,
20
21
    Tagger,
21
22
    TestCase,
22
23
    TestResult,
858
859
             ('stopTest', self),
859
860
             ], events)
860
861
 
 
862
    def test_local_tags_dont_leak(self):
 
863
        # A tag set during a test is local to that test and is not set during
 
864
        # the tests that follow.
 
865
        [result], events = self.make_results(1)
 
866
        a, b = PlaceHolder('a'), PlaceHolder('b')
 
867
        result.time(1)
 
868
        result.startTest(a)
 
869
        result.tags(set(['foo']), set([]))
 
870
        result.time(2)
 
871
        result.addSuccess(a)
 
872
        result.stopTest(a)
 
873
        result.time(3)
 
874
        result.startTest(b)
 
875
        result.time(4)
 
876
        result.addSuccess(b)
 
877
        result.stopTest(b)
 
878
        self.assertEqual(
 
879
            [('time', 1),
 
880
             ('startTest', a),
 
881
             ('time', 2),
 
882
             ('tags', set(['foo']), set()),
 
883
             ('addSuccess', a),
 
884
             ('stopTest', a),
 
885
             ('time', 3),
 
886
             ('startTest', b),
 
887
             ('time', 4),
 
888
             ('addSuccess', b),
 
889
             ('stopTest', b),
 
890
             ], events)
 
891
 
861
892
    def test_startTestRun(self):
862
893
        # Calls to startTestRun are not batched, because we are only
863
894
        # interested in sending tests atomically, not the whole run.