summaryrefslogtreecommitdiff
path: root/python
diff options
context:
space:
mode:
authorJonathan Lange <jml@canonical.com>2011-02-11 16:25:36 +0000
committerJonathan Lange <jml@canonical.com>2011-02-11 16:25:36 +0000
commita079bfb4c2a37a7d12b0f2cff51f079bf81c889f (patch)
treebbb895e05f8558edc5f41027a8dd3d6937b63981 /python
parentb32d51316660c0923eb132f0e3aaadd5b269bea9 (diff)
downloadsubunit-git-a079bfb4c2a37a7d12b0f2cff51f079bf81c889f.tar.gz
Clarity
Diffstat (limited to 'python')
-rw-r--r--python/subunit/tests/test_subunit_filter.py22
1 files changed, 16 insertions, 6 deletions
diff --git a/python/subunit/tests/test_subunit_filter.py b/python/subunit/tests/test_subunit_filter.py
index 69e32a0..89f5212 100644
--- a/python/subunit/tests/test_subunit_filter.py
+++ b/python/subunit/tests/test_subunit_filter.py
@@ -34,6 +34,10 @@ def make_stream(bytes):
class TestTestResultFilter(unittest.TestCase):
"""Test for TestResultFilter, a TestResult object which filters tests."""
+ # While TestResultFilter works on python objects, using a subunit stream
+ # is an easy pithy way of getting a series of test objects to call into
+ # the TestResult, and as TestResultFilter is intended for use with subunit
+ # also has the benefit of detecting any interface skew issues.
example_subunit_stream = """\
tags: global
test passed
@@ -51,6 +55,18 @@ test todo
xfail todo
"""
+ def run_tests(self, result_filter, input_stream=None):
+ """Run tests through the given filter.
+
+ :param result_filter: A filtering TestResult object.
+ :param input_stream: Bytes of subunit stream data. If not provided,
+ uses TestTestResultFilter.example_subunit_stream.
+ """
+ if input_stream is None:
+ input_stream = self.example_subunit_stream
+ test = subunit.ProtocolTestCase(make_stream(input_stream))
+ test.run(result_filter)
+
def test_default(self):
"""The default is to exclude success and include everything else."""
filtered_result = unittest.TestResult()
@@ -119,12 +135,6 @@ xfail todo
# Only success should pass
self.assertEqual(1, filtered_result.testsRun)
- def run_tests(self, result_filter, input_stream=None):
- if input_stream is None:
- input_stream = self.example_subunit_stream
- test = subunit.ProtocolTestCase(make_stream(input_stream))
- test.run(result_filter)
-
def test_suite():
loader = subunit.tests.TestUtil.TestLoader()