summaryrefslogtreecommitdiff
path: root/python
diff options
context:
space:
mode:
authorRobert Collins <robertc@robertcollins.net>2009-10-11 08:35:19 +1100
committerRobert Collins <robertc@robertcollins.net>2009-10-11 08:35:19 +1100
commit31a6e9bb2dcce48fe6aabe1cf6cd6bc566820b2f (patch)
tree12e47d0c19fb5e3a2acd6eaaf223e62670277ccf /python
parent14ee0c9ccc1b3130a46938adaab9f5d629e9a2a7 (diff)
downloadsubunit-git-31a6e9bb2dcce48fe6aabe1cf6cd6bc566820b2f.tar.gz
multipart details trigger the parser to detect interrupted streams too.
Diffstat (limited to 'python')
-rw-r--r--python/subunit/__init__.py10
-rw-r--r--python/subunit/tests/test_test_protocol.py74
2 files changed, 34 insertions, 50 deletions
diff --git a/python/subunit/__init__.py b/python/subunit/__init__.py
index bc67921..c7edf6e 100644
--- a/python/subunit/__init__.py
+++ b/python/subunit/__init__.py
@@ -241,11 +241,11 @@ class _ParserState(object):
class _InTest(_ParserState):
"""State for the subunit parser after reading a test: directive."""
- def _outcome(self, offset, line, no_details, simple_details_state):
+ def _outcome(self, offset, line, no_details, details_state):
"""An outcome directive has been read.
:param no_details: Callable to call when no details are presented.
- :param simple_details_state: The state to switch to for simple details
+ :param details_state: The state to switch to for details
processing of this outcome.
"""
if self.parser.current_test_description == line[offset:-1]:
@@ -255,7 +255,11 @@ class _InTest(_ParserState):
self.parser.client.stopTest(self.parser._current_test)
self.parser._current_test = None
elif self.parser.current_test_description + " [" == line[offset:-1]:
- self.parser._state = simple_details_state
+ self.parser._state = details_state
+ self.parser._message = ""
+ elif self.parser.current_test_description + " [ multipart" == \
+ line[offset:-1]:
+ self.parser._state = details_state
self.parser._message = ""
else:
self.parser.stdOutLineReceived(line)
diff --git a/python/subunit/tests/test_test_protocol.py b/python/subunit/tests/test_test_protocol.py
index 41fc6b4..ac8733d 100644
--- a/python/subunit/tests/test_test_protocol.py
+++ b/python/subunit/tests/test_test_protocol.py
@@ -388,18 +388,24 @@ class TestTestProtocolServerLostConnection(unittest.TestCase):
(self.test, subunit.RemoteError(""))])
self.assertEqual(self.client.success_calls, [])
- def test_lost_connection_during_error(self):
+ def do_connection_lost(self, outcome, opening):
self.protocol.lineReceived("test old mcdonald\n")
- self.protocol.lineReceived("error old mcdonald [\n")
+ self.protocol.lineReceived("%s old mcdonald %s" % (outcome, opening))
self.protocol.lostConnection()
self.assertEqual(self.client.start_calls, [self.test])
self.assertEqual(self.client.end_calls, [self.test])
self.assertEqual(self.client.error_calls, [
- (self.test, subunit.RemoteError("lost connection during error "
- "report of test 'old mcdonald'"))])
+ (self.test, subunit.RemoteError("lost connection during %s "
+ "report of test 'old mcdonald'" % outcome))])
self.assertEqual(self.client.failure_calls, [])
self.assertEqual(self.client.success_calls, [])
+ def test_lost_connection_during_error(self):
+ self.do_connection_lost("error", "[\n")
+
+ def test_lost_connection_during_error_details(self):
+ self.do_connection_lost("error", "[ multipart\n")
+
def test_lost_connected_after_failure(self):
self.protocol.lineReceived("test old mcdonald\n")
self.protocol.lineReceived("failure old mcdonald\n")
@@ -413,18 +419,10 @@ class TestTestProtocolServerLostConnection(unittest.TestCase):
self.assertEqual(self.client.success_calls, [])
def test_lost_connection_during_failure(self):
- self.protocol.lineReceived("test old mcdonald\n")
- self.protocol.lineReceived("failure old mcdonald [\n")
- self.protocol.lostConnection()
- self.assertEqual(self.client.start_calls, [self.test])
- self.assertEqual(self.client.end_calls, [self.test])
- self.assertEqual(self.client.error_calls,
- [(self.test,
- subunit.RemoteError("lost connection during "
- "failure report"
- " of test 'old mcdonald'"))])
- self.assertEqual(self.client.failure_calls, [])
- self.assertEqual(self.client.success_calls, [])
+ self.do_connection_lost("failure", "[\n")
+
+ def test_lost_connection_during_failure_details(self):
+ self.do_connection_lost("failure", "[ multipart\n")
def test_lost_connection_after_success(self):
self.protocol.lineReceived("test old mcdonald\n")
@@ -436,41 +434,23 @@ class TestTestProtocolServerLostConnection(unittest.TestCase):
self.assertEqual(self.client.failure_calls, [])
self.assertEqual(self.client.success_calls, [self.test])
+ def test_lost_connection_during_success(self):
+ self.do_connection_lost("success", "[\n")
+
+ def test_lost_connection_during_success_details(self):
+ self.do_connection_lost("success", "[ multipart\n")
+
def test_lost_connection_during_skip(self):
- self.protocol.lineReceived("test old mcdonald\n")
- self.protocol.lineReceived("skip old mcdonald [\n")
- self.protocol.lostConnection()
- self.assertEqual(self.client.start_calls, [self.test])
- self.assertEqual(self.client.end_calls, [self.test])
- self.assertEqual(self.client.error_calls, [
- (self.test, subunit.RemoteError("lost connection during skip "
- "report of test 'old mcdonald'"))])
- self.assertEqual(self.client.failure_calls, [])
- self.assertEqual(self.client.success_calls, [])
+ self.do_connection_lost("skip", "[\n")
+
+ def test_lost_connection_during_skip_details(self):
+ self.do_connection_lost("skip", "[ multipart\n")
def test_lost_connection_during_xfail(self):
- self.protocol.lineReceived("test old mcdonald\n")
- self.protocol.lineReceived("xfail old mcdonald [\n")
- self.protocol.lostConnection()
- self.assertEqual(self.client.start_calls, [self.test])
- self.assertEqual(self.client.end_calls, [self.test])
- self.assertEqual(self.client.error_calls, [
- (self.test, subunit.RemoteError("lost connection during xfail "
- "report of test 'old mcdonald'"))])
- self.assertEqual(self.client.failure_calls, [])
- self.assertEqual(self.client.success_calls, [])
+ self.do_connection_lost("xfail", "[\n")
- def test_lost_connection_during_success(self):
- self.protocol.lineReceived("test old mcdonald\n")
- self.protocol.lineReceived("success old mcdonald [\n")
- self.protocol.lostConnection()
- self.assertEqual(self.client.start_calls, [self.test])
- self.assertEqual(self.client.end_calls, [self.test])
- self.assertEqual(self.client.error_calls, [
- (self.test, subunit.RemoteError("lost connection during success "
- "report of test 'old mcdonald'"))])
- self.assertEqual(self.client.failure_calls, [])
- self.assertEqual(self.client.success_calls, [])
+ def test_lost_connection_during_xfail_details(self):
+ self.do_connection_lost("xfail", "[ multipart\n")
class TestTestProtocolServerAddError(unittest.TestCase):