diff options
| author | Jonathan Lange <jml@mumak.net> | 2006-12-02 15:43:25 +1100 |
|---|---|---|
| committer | Jonathan Lange <jml@mumak.net> | 2006-12-02 15:43:25 +1100 |
| commit | 472b3ae396f3649158cbd776e42bda53a8f800a8 (patch) | |
| tree | 85bff2ecf97abc8a711ca35f37e8a9e1b3fbb01b /python | |
| parent | bb7e4124b6d945551c5e4444a8f5b44dac211d74 (diff) | |
| download | subunit-git-472b3ae396f3649158cbd776e42bda53a8f800a8.tar.gz | |
Clarify the line-handling logic
Diffstat (limited to 'python')
| -rw-r--r-- | python/subunit/__init__.py | 38 |
1 files changed, 13 insertions, 25 deletions
diff --git a/python/subunit/__init__.py b/python/subunit/__init__.py index f171f78..922c53f 100644 --- a/python/subunit/__init__.py +++ b/python/subunit/__init__.py @@ -119,32 +119,20 @@ class TestProtocolServer(object): elif (self.state == TestProtocolServer.READING_FAILURE or self.state == TestProtocolServer.READING_ERROR): self._appendMessage(line) - elif line.startswith("test:"): - self._startTest(6, line) - elif line.startswith("testing:"): - self._startTest(9, line) - elif line.startswith("testing"): - self._startTest(8, line) - elif line.startswith("test"): - self._startTest(5, line) - elif line.startswith("error:"): - self._addError(7, line) - elif line.startswith("error"): - self._addError(6, line) - elif line.startswith("failure:"): - self._addFailure(9, line) - elif line.startswith("failure"): - self._addFailure(8, line) - elif line.startswith("successful:"): - self._addSuccess(12, line) - elif line.startswith("successful"): - self._addSuccess(11, line) - elif line.startswith("success:"): - self._addSuccess(9, line) - elif line.startswith("success"): - self._addSuccess(8, line) else: - self.stdOutLineReceived(line) + cmd, rest = line.split(None, 1) + offset = len(cmd) + 1 + cmd = cmd.strip(':') + if cmd in ('test', 'testing'): + self._startTest(offset, line) + elif cmd == 'error': + self._addError(offset, line) + elif cmd == 'failure': + self._addFailure(offset, line) + elif cmd in ('success', 'successful'): + self._addSuccess(offset, line) + else: + self.stdOutLineReceived(line) def lostConnection(self): """The input connection has finished.""" |
