summaryrefslogtreecommitdiff
path: root/lib/subunit/python
diff options
context:
space:
mode:
authorJelmer Vernooij <jelmer@samba.org>2011-11-13 17:17:54 +0100
committerJelmer Vernooij <jelmer@samba.org>2011-11-13 18:06:06 +0100
commit9250177ae71e37fe1a132fe198cac4f3512bc4c7 (patch)
tree431383b939c5fe2005eedc5894ca182958418083 /lib/subunit/python
parent0966be49a0b7d1cea7d8afc9b0c313a8198bde66 (diff)
downloadsamba-9250177ae71e37fe1a132fe198cac4f3512bc4c7.tar.gz
samba-9250177ae71e37fe1a132fe198cac4f3512bc4c7.tar.bz2
samba-9250177ae71e37fe1a132fe198cac4f3512bc4c7.zip
subunit: Import new upstream snapshot.
Diffstat (limited to 'lib/subunit/python')
-rwxr-xr-xlib/subunit/python/subunit/run.py2
-rw-r--r--lib/subunit/python/subunit/tests/__init__.py2
-rw-r--r--lib/subunit/python/subunit/tests/test_run.py52
-rw-r--r--lib/subunit/python/subunit/tests/test_test_protocol.py17
4 files changed, 68 insertions, 5 deletions
diff --git a/lib/subunit/python/subunit/run.py b/lib/subunit/python/subunit/run.py
index 51d6837aab..ca5fe5c17e 100755
--- a/lib/subunit/python/subunit/run.py
+++ b/lib/subunit/python/subunit/run.py
@@ -23,6 +23,7 @@
import sys
from subunit import TestProtocolClient, get_default_formatter
+from subunit.test_results import AutoTimingTestResultDecorator
from testtools.run import (
BUFFEROUTPUT,
CATCHBREAK,
@@ -39,6 +40,7 @@ class SubunitTestRunner(object):
def run(self, test):
"Run the given test case or test suite."
result = TestProtocolClient(self.stream)
+ result = AutoTimingTestResultDecorator(result)
test(result)
return result
diff --git a/lib/subunit/python/subunit/tests/__init__.py b/lib/subunit/python/subunit/tests/__init__.py
index a78cec8572..e0e1eb1b04 100644
--- a/lib/subunit/python/subunit/tests/__init__.py
+++ b/lib/subunit/python/subunit/tests/__init__.py
@@ -19,6 +19,7 @@ from subunit.tests import (
test_chunked,
test_details,
test_progress_model,
+ test_run,
test_subunit_filter,
test_subunit_stats,
test_subunit_tags,
@@ -38,4 +39,5 @@ def test_suite():
result.addTest(test_subunit_filter.test_suite())
result.addTest(test_subunit_tags.test_suite())
result.addTest(test_subunit_stats.test_suite())
+ result.addTest(test_run.test_suite())
return result
diff --git a/lib/subunit/python/subunit/tests/test_run.py b/lib/subunit/python/subunit/tests/test_run.py
new file mode 100644
index 0000000000..5a96bcf30e
--- /dev/null
+++ b/lib/subunit/python/subunit/tests/test_run.py
@@ -0,0 +1,52 @@
+#
+# subunit: extensions to python unittest to get test results from subprocesses.
+# Copyright (C) 2011 Robert Collins <robertc@robertcollins.net>
+#
+# Licensed under either the Apache License, Version 2.0 or the BSD 3-clause
+# license at the users choice. A copy of both licenses are available in the
+# project source as Apache-2.0 and BSD. You may not use this file except in
+# compliance with one of these two licences.
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under these licenses is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+# license you chose for the specific language governing permissions and
+# limitations under that license.
+#
+
+from cStringIO import StringIO
+import unittest
+
+from testtools import PlaceHolder
+
+import subunit
+from subunit.run import SubunitTestRunner
+
+
+def test_suite():
+ loader = subunit.tests.TestUtil.TestLoader()
+ result = loader.loadTestsFromName(__name__)
+ return result
+
+
+class TimeCollectingTestResult(unittest.TestResult):
+
+ def __init__(self, *args, **kwargs):
+ super(TimeCollectingTestResult, self).__init__(*args, **kwargs)
+ self.time_called = []
+
+ def time(self, a_time):
+ self.time_called.append(a_time)
+
+
+class TestSubunitTestRunner(unittest.TestCase):
+
+ def test_includes_timing_output(self):
+ io = StringIO()
+ runner = SubunitTestRunner(stream=io)
+ test = PlaceHolder('name')
+ runner.run(test)
+ client = TimeCollectingTestResult()
+ io.seek(0)
+ subunit.TestProtocolServer(client).readFrom(io)
+ self.assertTrue(len(client.time_called) > 0)
diff --git a/lib/subunit/python/subunit/tests/test_test_protocol.py b/lib/subunit/python/subunit/tests/test_test_protocol.py
index 03d921abf1..c93aabd80c 100644
--- a/lib/subunit/python/subunit/tests/test_test_protocol.py
+++ b/lib/subunit/python/subunit/tests/test_test_protocol.py
@@ -22,11 +22,18 @@ from testtools import skipIf, TestCase
from testtools.compat import _b, _u, BytesIO, StringIO
from testtools.content import Content, TracebackContent
from testtools.content_type import ContentType
-from testtools.tests.helpers import (
- Python26TestResult,
- Python27TestResult,
- ExtendedTestResult,
- )
+try:
+ from testtools.testresult.doubles import (
+ Python26TestResult,
+ Python27TestResult,
+ ExtendedTestResult,
+ )
+except ImportError:
+ from testtools.tests.helpers import (
+ Python26TestResult,
+ Python27TestResult,
+ ExtendedTestResult,
+ )
import subunit
from subunit import _remote_exception_str, _remote_exception_str_chunked