~thomir-deactivatedaccount/subunit/vcs-debian-fixed

« back to all changes in this revision

Viewing changes to python/subunit/tests/test_test_protocol2.py

  • Committer: Jelmer Vernooij
  • Date: 2013-09-11 20:23:43 UTC
  • mfrom: (64.24.14)
  • Revision ID: jelmer@samba.org-20130911202343-gdfhxfp05rnto7u4
New upstream release.

Show diffs side-by-side

added added

removed removed

Lines of Context:
18
18
import datetime
19
19
 
20
20
from testtools import TestCase
21
 
from testtools.matchers import HasLength
 
21
from testtools.matchers import Contains, HasLength
22
22
from testtools.tests.test_testresult import TestStreamResultContract
23
23
from testtools.testresult.doubles import StreamResult
24
24
 
38
38
CONSTANT_TIMESTAMP = b'\xb3+\x03\x13<\x17T\xcf\x80\xaf\xc8\x03barI\x96>-'
39
39
CONSTANT_ROUTE_CODE = b'\xb3-\x03\x13\x03bar\x06source\x9cY9\x19'
40
40
CONSTANT_RUNNABLE = b'\xb3(\x03\x0c\x03foo\xe3\xea\xf5\xa4'
41
 
CONSTANT_TAGS = b'\xb3)\x80\x15\x03bar\x02\x03foo\x03barTHn\xb4'
 
41
CONSTANT_TAGS = [
 
42
    b'\xb3)\x80\x15\x03bar\x02\x03foo\x03barTHn\xb4',
 
43
    b'\xb3)\x80\x15\x03bar\x02\x03bar\x03foo\xf8\xf1\x91o',
 
44
    ]
42
45
 
43
46
 
44
47
class TestStreamResultToBytesContract(TestCase, TestStreamResultContract):
202
205
    def test_tags(self):
203
206
        result, output = self._make_result()
204
207
        result.status(test_id="bar", test_tags=set(['foo', 'bar']))
205
 
        self.assertEqual(CONSTANT_TAGS, output.getvalue())
 
208
        self.assertThat(CONSTANT_TAGS, Contains(output.getvalue()))
206
209
 
207
210
    def test_timestamp(self):
208
211
        timestamp = datetime.datetime(2001, 12, 12, 12, 59, 59, 45,
300
303
            source, non_subunit_name="stdout").run(result)
301
304
        self.assertEqual(b'', source.read())
302
305
        self.assertEqual(events, result._events)
 
306
        #- any file attachments should be byte contents [as users assume that].
 
307
        for event in result._events:
 
308
            if event[5] is not None:
 
309
                self.assertIsInstance(event[6], bytes)
303
310
 
304
311
    def check_event(self, source_bytes, test_status=None, test_id="foo",
305
312
        route_code=None, timestamp=None, tags=None, mime_type=None,
357
364
            test_status='success', runnable=False)
358
365
 
359
366
    def test_tags(self):
360
 
        self.check_event(CONSTANT_TAGS,
 
367
        self.check_event(CONSTANT_TAGS[0],
361
368
            None, tags=set(['foo', 'bar']), test_id="bar")
362
369
 
363
370
    def test_timestamp(self):
415
422
            file_bytes=b'foo')
416
423
        self.check_event(content.getvalue(), test_id=None, file_name='bar',
417
424
            route_code='0', mime_type='text/plain', file_bytes=b'foo')
418
 
 
419
 
 
420
 
def test_suite():
421
 
    loader = subunit.tests.TestUtil.TestLoader()
422
 
    result = loader.loadTestsFromName(__name__)
423
 
    return result