Tag support has been implemented for TestProtocolClient.

(Robert Collins, #518016)
This commit is contained in:
Robert Collins
2012-01-11 18:42:53 +13:00
parent ec629cf047
commit 25581a35bb
3 changed files with 28 additions and 0 deletions

3
NEWS
View File

@@ -22,6 +22,9 @@ BUG FIXES
'--no-xfail', '--no-passthrough, '--no-success', and gives you just the
failure stream. (John Arbash Meinel)
* Tag support has been implemented for TestProtocolClient.
(Robert Collins, #518016)
* Test suite works with latest testtools (but not older ones - formatting
changes only). (Robert Collins)

View File

@@ -755,6 +755,15 @@ class TestProtocolClient(testresult.TestResult):
self._stream.write(self._progress_fmt + prefix + offset +
self._bytes_eol)
def tags(self, new_tags, gone_tags):
"""Inform the client about tags added/removed from the stream."""
if not new_tags and not gone_tags:
return
tags = set([tag.encode('utf8') for tag in new_tags])
tags.update([_b("-") + tag.encode('utf8') for tag in gone_tags])
tag_line = _b("tags: ") + _b(" ").join(tags) + _b("\n")
self._stream.write(tag_line)
def time(self, a_datetime):
"""Inform the client of the time.

View File

@@ -1299,6 +1299,22 @@ class TestTestProtocolClient(unittest.TestCase):
"something\n"
"F\r\nserialised\nform0\r\n]\n" % self.test.id()))
def test_tags_empty(self):
self.protocol.tags(set(), set())
self.assertEqual(_b(""), self.io.getvalue())
def test_tags_add(self):
self.protocol.tags(set(['foo']), set())
self.assertEqual(_b("tags: foo\n"), self.io.getvalue())
def test_tags_both(self):
self.protocol.tags(set(['quux']), set(['bar']))
self.assertEqual(_b("tags: quux -bar\n"), self.io.getvalue())
def test_tags_gone(self):
self.protocol.tags(set(), set(['bar']))
self.assertEqual(_b("tags: -bar\n"), self.io.getvalue())
def test_suite():
loader = subunit.tests.TestUtil.TestLoader()