summaryrefslogtreecommitdiff
path: root/python
diff options
context:
space:
mode:
authorRobert Collins <robertc@robertcollins.net>2010-01-16 10:02:12 +1100
committerRobert Collins <robertc@robertcollins.net>2010-01-16 10:02:12 +1100
commit1fcae436eddfb4bf36fd99ddde1558b526f3ccdb (patch)
treeed0f8dd9b55b710796d283dcac51e2dbc9f62da0 /python
parentc4f8f21ed5269848c0bbc8e999478b402bc1fe5a (diff)
downloadsubunit-git-1fcae436eddfb4bf36fd99ddde1558b526f3ccdb.tar.gz
Only take commands that start the line they are observed on.
Diffstat (limited to 'python')
-rw-r--r--python/subunit/__init__.py4
-rw-r--r--python/subunit/tests/test_test_protocol.py4
2 files changed, 6 insertions, 2 deletions
diff --git a/python/subunit/__init__.py b/python/subunit/__init__.py
index 6e8df90..73dbc17 100644
--- a/python/subunit/__init__.py
+++ b/python/subunit/__init__.py
@@ -213,10 +213,10 @@ class _ParserState(object):
def lineReceived(self, line):
"""a line has been received."""
parts = line.split(None, 1)
- if len(parts) == 2:
+ if len(parts) == 2 and line.startswith(parts[0]):
cmd, rest = parts
offset = len(cmd) + 1
- cmd = cmd.strip(':')
+ cmd = cmd.rstrip(':')
if cmd in ('test', 'testing'):
self.startTest(offset, line)
elif cmd == 'error':
diff --git a/python/subunit/tests/test_test_protocol.py b/python/subunit/tests/test_test_protocol.py
index 9e9db18..f10380b 100644
--- a/python/subunit/tests/test_test_protocol.py
+++ b/python/subunit/tests/test_test_protocol.py
@@ -124,6 +124,10 @@ class TestTestProtocolServerStartTest(unittest.TestCase):
self.assertEqual(self.client._events,
[('startTest', subunit.RemotedTestCase("old mcdonald"))])
+ def test_indented_test_colon_ignored(self):
+ self.protocol.lineReceived(" test: old mcdonald\n")
+ self.assertEqual([], self.client._events)
+
def test_start_testing_colon(self):
self.protocol.lineReceived("testing: old mcdonald\n")
self.assertEqual(self.client._events,