summaryrefslogtreecommitdiff
path: root/python
diff options
context:
space:
mode:
authorRobert Collins <robertc@robertcollins.net>2012-01-11 18:42:53 +1300
committerRobert Collins <robertc@robertcollins.net>2012-01-11 18:42:53 +1300
commit25581a35bb8b7468dd0e3ada1f5b20555e8eab30 (patch)
tree04463a3a6c1fa16966b0b640769919ab5373f470 /python
parentec629cf047c0f4e1d2d51d30a3d72e5437017936 (diff)
downloadsubunit-git-25581a35bb8b7468dd0e3ada1f5b20555e8eab30.tar.gz
Tag support has been implemented for TestProtocolClient.
(Robert Collins, #518016)
Diffstat (limited to 'python')
-rw-r--r--python/subunit/__init__.py9
-rw-r--r--python/subunit/tests/test_test_protocol.py16
2 files changed, 25 insertions, 0 deletions
diff --git a/python/subunit/__init__.py b/python/subunit/__init__.py
index b4c9397..b30b8fe 100644
--- a/python/subunit/__init__.py
+++ b/python/subunit/__init__.py
@@ -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.
diff --git a/python/subunit/tests/test_test_protocol.py b/python/subunit/tests/test_test_protocol.py
index 019c080..091b370 100644
--- a/python/subunit/tests/test_test_protocol.py
+++ b/python/subunit/tests/test_test_protocol.py
@@ -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()