summaryrefslogtreecommitdiff
path: root/python
diff options
context:
space:
mode:
authorJonathan Lange <jml@canonical.com>2011-02-11 16:22:21 +0000
committerJonathan Lange <jml@canonical.com>2011-02-11 16:22:21 +0000
commit8313ffeb9ad36af77d29724e29b1801d80f8df7c (patch)
tree9187026b2a8b4814e2fba9df5e450fa219ac06cf /python
parent14c50a345f9867424d69531822b0e8dd420742d2 (diff)
downloadsubunit-git-8313ffeb9ad36af77d29724e29b1801d80f8df7c.tar.gz
Try to make the test set up a little more data driven.
Diffstat (limited to 'python')
-rw-r--r--python/subunit/tests/test_subunit_filter.py52
1 files changed, 26 insertions, 26 deletions
diff --git a/python/subunit/tests/test_subunit_filter.py b/python/subunit/tests/test_subunit_filter.py
index ac46f15..2f26f39 100644
--- a/python/subunit/tests/test_subunit_filter.py
+++ b/python/subunit/tests/test_subunit_filter.py
@@ -23,9 +23,34 @@ import subunit
from subunit.test_results import TestResultFilter
+def make_stream(bytes):
+ """Take a string and return a stream from which that string can be read."""
+ stream = StringIO()
+ stream.write(bytes)
+ stream.seek(0)
+ return stream
+
+
class TestTestResultFilter(unittest.TestCase):
"""Test for TestResultFilter, a TestResult object which filters tests."""
+ example_subunit_stream = """\
+tags: global
+test passed
+success passed
+test failed
+tags: local
+failure failed
+test error
+error error [
+error details
+]
+test skipped
+skip skipped
+test todo
+xfail todo
+"""
+
def test_default(self):
"""The default is to exclude success and include everything else."""
filtered_result = unittest.TestResult()
@@ -95,35 +120,10 @@ class TestTestResultFilter(unittest.TestCase):
self.assertEqual(1, filtered_result.testsRun)
def run_tests(self, result_filter):
- input_stream = self.getTestStream()
+ input_stream = make_stream(self.example_subunit_stream)
test = subunit.ProtocolTestCase(input_stream)
test.run(result_filter)
- def getTestStream(self):
- # 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.
- input_stream = StringIO()
- input_stream.write("""tags: global
-test passed
-success passed
-test failed
-tags: local
-failure failed
-test error
-error error [
-error details
-]
-test skipped
-skip skipped
-test todo
-xfail todo
-""")
- input_stream.seek(0)
- return input_stream
-
def test_suite():
loader = subunit.tests.TestUtil.TestLoader()