summaryrefslogtreecommitdiff
path: root/python/subunit/__init__.py
diff options
context:
space:
mode:
authorRobert Collins <robertc@robertcollins.net>2009-08-08 17:03:38 +1000
committerRobert Collins <robertc@robertcollins.net>2009-08-08 17:03:38 +1000
commit4b0fa892e407c70092335aa478ddf578153002b0 (patch)
tree15d15c7208e43515435d4ed8f6d0a7f4d588b929 /python/subunit/__init__.py
parent10d68f9747c716157036ebd9768c1aeb52a3f50a (diff)
downloadsubunit-4b0fa892e407c70092335aa478ddf578153002b0.tar.gz
Extend the progress model to support a push/pop model.
Diffstat (limited to 'python/subunit/__init__.py')
-rw-r--r--python/subunit/__init__.py36
1 files changed, 26 insertions, 10 deletions
diff --git a/python/subunit/__init__.py b/python/subunit/__init__.py
index f474bd9..27d9e53 100644
--- a/python/subunit/__init__.py
+++ b/python/subunit/__init__.py
@@ -28,8 +28,10 @@ import unittest
import iso8601
-SEEK_CUR = os.SEEK_CUR
-SEEK_SET = os.SEEK_SET
+PROGRESS_SET = 0
+PROGRESS_CUR = 1
+PROGRESS_PUSH = 2
+PROGRESS_POP = 3
def test_suite():
@@ -225,10 +227,17 @@ class TestProtocolServer(object):
"""Process a progress directive."""
line = line[offset:].strip()
if line[0] in '+-':
- whence = SEEK_CUR
+ whence = PROGRESS_CUR
+ delta = int(line)
+ elif line == "push":
+ whence = PROGRESS_PUSH
+ delta = None
+ elif line == "pop":
+ whence = PROGRESS_POP
+ delta = None
else:
- whence = SEEK_SET
- delta = int(line)
+ whence = PROGRESS_SET
+ delta = int(line)
progress_method = getattr(self.client, 'progress', None)
if callable(progress_method):
progress_method(delta, whence)
@@ -394,13 +403,20 @@ class TestProtocolClient(unittest.TestResult):
"""Provide indication about the progress/length of the test run.
:param offset: Information about the number of tests remaining. If
- whence is SEEK_CUR, then offset increases/decreases the remaining
- test count. If whence is SEEK_SET, then offset specifies exactly
- the remaining test count.
- :param whence: One of SEEK_CUR or SEEK_SET.
+ whence is PROGRESS_CUR, then offset increases/decreases the
+ remaining test count. If whence is PROGRESS_SET, then offset
+ specifies exactly the remaining test count.
+ :param whence: One of PROGRESS_CUR, PROGRESS_SET, PROGRESS_PUSH,
+ PROGRESS_POP.
"""
- if whence == SEEK_CUR and offset > -1:
+ if whence == PROGRESS_CUR and offset > -1:
prefix = "+"
+ elif whence == PROGRESS_PUSH:
+ prefix = ""
+ offset = "push"
+ elif whence == PROGRESS_POP:
+ prefix = ""
+ offset = "pop"
else:
prefix = ""
self._stream.write("progress: %s%s\n" % (prefix, offset))