summaryrefslogtreecommitdiff
path: root/python/subunit/__init__.py
diff options
context:
space:
mode:
authorRobert Collins <robertc@robertcollins.net>2008-12-07 14:37:48 +1100
committerRobert Collins <robertc@robertcollins.net>2008-12-07 14:37:48 +1100
commit9a915af1f70344c63f232a2d82d14cf6e01aa84f (patch)
treed44b7ca9d66d22d0bff430f077d42555f6d9ab0a /python/subunit/__init__.py
parent5c3c88265d467555e2e92f1a7f445f69b3c0a261 (diff)
downloadsubunit-git-9a915af1f70344c63f232a2d82d14cf6e01aa84f.tar.gz
Add XFAIL support. As with Skip, there is no python object representation of the skip, because there is no standard for reporting them.
Diffstat (limited to 'python/subunit/__init__.py')
-rw-r--r--python/subunit/__init__.py21
1 files changed, 20 insertions, 1 deletions
diff --git a/python/subunit/__init__.py b/python/subunit/__init__.py
index 4c7cf57..b2d1ad8 100644
--- a/python/subunit/__init__.py
+++ b/python/subunit/__init__.py
@@ -50,6 +50,7 @@ class TestProtocolServer(object):
READING_FAILURE = 2
READING_ERROR = 3
READING_SKIP = 4
+ READING_XFAIL = 5
def __init__(self, client, stream=sys.stdout):
"""Create a TestProtocol server instance.
@@ -81,6 +82,20 @@ class TestProtocolServer(object):
else:
self.stdOutLineReceived(line)
+ def _addExpectedFail(self, offset, line):
+ if (self.state == TestProtocolServer.TEST_STARTED and
+ self.current_test_description == line[offset:-1]):
+ self.state = TestProtocolServer.OUTSIDE_TEST
+ self.current_test_description = None
+ self.client.addSuccess(self._current_test)
+ self.client.stopTest(self._current_test)
+ elif (self.state == TestProtocolServer.TEST_STARTED and
+ self.current_test_description + " [" == line[offset:-1]):
+ self.state = TestProtocolServer.READING_XFAIL
+ self._message = ""
+ else:
+ self.stdOutLineReceived(line)
+
def _addFailure(self, offset, line):
if (self.state == TestProtocolServer.TEST_STARTED and
self.current_test_description == line[offset:-1]):
@@ -136,7 +151,9 @@ class TestProtocolServer(object):
self.client.addError(self._current_test,
RemoteError(self._message))
self.client.stopTest(self._current_test)
- elif self.state == TestProtocolServer.READING_SKIP:
+ elif self.state in (
+ TestProtocolServer.READING_SKIP,
+ TestProtocolServer.READING_XFAIL):
self._succeedTest()
else:
self.stdOutLineReceived(line)
@@ -164,6 +181,8 @@ class TestProtocolServer(object):
self._addSkip(offset, line)
elif cmd in ('success', 'successful'):
self._addSuccess(offset, line)
+ elif cmd == 'xfail':
+ self._addExpectedFail(offset, line)
else:
self.stdOutLineReceived(line)
else: