316
300
raise RuntimeError("%s failed: %s" % (command, err))
319
def to_events(self, stream):
320
test = subunit.ProtocolTestCase(BytesIO(stream))
321
result = ExtendedTestResult()
323
return result._events
325
303
def test_default(self):
326
output = self.run_command([], _b(
330
events = self.to_events(output)
331
foo = subunit.RemotedTestCase('foo')
334
('addSkip', foo, {}),
304
byte_stream = BytesIO()
305
stream = StreamResultToBytes(byte_stream)
306
stream.status(test_id="foo", test_status="inprogress")
307
stream.status(test_id="foo", test_status="skip")
308
output = self.run_command([], byte_stream.getvalue())
309
events = StreamResult()
310
ByteStreamToStreamResult(BytesIO(output)).run(events)
311
ids = set(event[1] for event in events._events)
313
('status', 'foo', 'inprogress'),
314
('status', 'foo', 'skip'),
315
], [event[:3] for event in events._events])
338
317
def test_tags(self):
339
output = self.run_command(['-s', '--with-tag', 'a'], _b(
350
events = self.to_events(output)
351
foo = subunit.RemotedTestCase('foo')
352
baz = subunit.RemotedTestCase('baz')
354
[('tags', set(['a']), set()),
358
('tags', set(), set(['a'])),
360
('tags', set(['a']), set()),
318
byte_stream = BytesIO()
319
stream = StreamResultToBytes(byte_stream)
321
test_id="foo", test_status="inprogress", test_tags=set(["a"]))
323
test_id="foo", test_status="success", test_tags=set(["a"]))
324
stream.status(test_id="bar", test_status="inprogress")
325
stream.status(test_id="bar", test_status="inprogress")
327
test_id="baz", test_status="inprogress", test_tags=set(["a"]))
329
test_id="baz", test_status="success", test_tags=set(["a"]))
330
output = self.run_command(
331
['-s', '--with-tag', 'a'], byte_stream.getvalue())
332
events = StreamResult()
333
ByteStreamToStreamResult(BytesIO(output)).run(events)
334
ids = set(event[1] for event in events._events)
335
self.assertEqual(set(['foo', 'baz']), ids)
337
def test_no_passthrough(self):
338
output = self.run_command(['--no-passthrough'], b'hi thar')
339
self.assertEqual(b'', output)
341
def test_passthrough(self):
342
output = self.run_command([], b'hi thar')
343
byte_stream = BytesIO()
344
stream = StreamResultToBytes(byte_stream)
345
for pos, _ in enumerate(b'hi thar'):
346
stream.status(file_name="stdout", file_bytes=b'hi thar'[pos:pos+1])
347
self.assertEqual(byte_stream.getvalue(), output)
367
350
def test_suite():