summaryrefslogtreecommitdiff
path: root/python/subunit
diff options
context:
space:
mode:
authorRobert Collins <robertc@robertcollins.net>2013-03-04 22:01:43 +1300
committerRobert Collins <robertc@robertcollins.net>2013-03-04 22:01:43 +1300
commit36de6f4f7542b10f93061b65bcf7464a74cb9ddc (patch)
tree4ab053e5cfe5ebcc2683049a63c647ab600d2266 /python/subunit
parent22ea5b6a1f0e008f449c5984e215a53073b8dbfe (diff)
downloadsubunit-git-36de6f4f7542b10f93061b65bcf7464a74cb9ddc.tar.gz
Enumerate tests before running (permits progress bars).
Diffstat (limited to 'python/subunit')
-rwxr-xr-xpython/subunit/run.py6
-rw-r--r--python/subunit/tests/test_run.py15
2 files changed, 20 insertions, 1 deletions
diff --git a/python/subunit/run.py b/python/subunit/run.py
index 2e07d86..612d7ea 100755
--- a/python/subunit/run.py
+++ b/python/subunit/run.py
@@ -24,6 +24,7 @@ import os
import sys
from testtools import ExtendedToStreamDecorator
+from testtools.testsuite import iterate_tests
from subunit import StreamResultToBytes, get_default_formatter
from subunit.test_results import AutoTimingTestResultDecorator
@@ -49,7 +50,10 @@ class SubunitTestRunner(object):
def run(self, test):
"Run the given test case or test suite."
- result = ExtendedToStreamDecorator(StreamResultToBytes(self.stream))
+ result = StreamResultToBytes(self.stream)
+ for case in iterate_tests(test):
+ result.status(test_id=case.id(), test_status='exists')
+ result = ExtendedToStreamDecorator(result)
result = AutoTimingTestResultDecorator(result)
if self.failfast is not None:
result.failfast = self.failfast
diff --git a/python/subunit/tests/test_run.py b/python/subunit/tests/test_run.py
index 2944419..209185d 100644
--- a/python/subunit/tests/test_run.py
+++ b/python/subunit/tests/test_run.py
@@ -43,3 +43,18 @@ class TestSubunitTestRunner(unittest.TestCase):
timestamps = [event[-1] for event in eventstream._events
if event is not None]
self.assertNotEqual([], timestamps)
+
+ def test_enumerates_tests_before_run(self):
+ io = BytesIO()
+ runner = SubunitTestRunner(stream=io)
+ test1 = PlaceHolder('name1')
+ test2 = PlaceHolder('name2')
+ case = unittest.TestSuite([test1, test2])
+ runner.run(case)
+ io.seek(0)
+ eventstream = StreamResult()
+ subunit.ByteStreamToStreamResult(io).run(eventstream)
+ self.assertEqual([
+ ('status', 'name1', 'exists'),
+ ('status', 'name2', 'exists'),
+ ], [event[:3] for event in eventstream._events[:2]])