diff options
| author | Jonathan Lange <jml@mumak.net> | 2012-04-10 16:10:34 +0100 |
|---|---|---|
| committer | Jonathan Lange <jml@mumak.net> | 2012-04-10 16:10:34 +0100 |
| commit | 8141fda3abe0ba97903dca15a40f37dfa4eebcb7 (patch) | |
| tree | 3454d0cc01d9ff03f275c673585964cc123044b2 /python | |
| parent | 6de2212472caa1e7abab5b0a517aebbaf483141e (diff) | |
| download | subunit-git-8141fda3abe0ba97903dca15a40f37dfa4eebcb7.tar.gz | |
Add tests that exercise the subunit-filter filter.
Diffstat (limited to 'python')
| -rw-r--r-- | python/subunit/tests/test_subunit_filter.py | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/python/subunit/tests/test_subunit_filter.py b/python/subunit/tests/test_subunit_filter.py index 5bbf581..1cae791 100644 --- a/python/subunit/tests/test_subunit_filter.py +++ b/python/subunit/tests/test_subunit_filter.py @@ -17,6 +17,9 @@ """Tests for subunit.TestResultFilter.""" from datetime import datetime +import os +import subprocess +import sys from subunit import iso8601 import unittest @@ -216,6 +219,58 @@ xfail todo ('stopTest', foo), ], result._events) +class TestFilterCommand(TestCase): + + example_subunit_stream = _b("""\ +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 run_command(self, args, stream): + root = os.path.dirname( + os.path.dirname(os.path.dirname(os.path.dirname(__file__)))) + script_path = os.path.join(root, 'filters', 'subunit-filter') + command = [sys.executable, script_path] + list(args) + ps = subprocess.Popen( + command, stdin=subprocess.PIPE, stdout=subprocess.PIPE, + stderr=subprocess.PIPE) + out, err = ps.communicate(stream) + if ps.returncode != 0: + raise RuntimeError("%s failed: %s" % (command, err)) + return out + + def to_events(self, stream): + test = subunit.ProtocolTestCase(BytesIO(stream)) + result = ExtendedTestResult() + test.run(result) + return result._events + + def test_default(self): + output = self.run_command([], ( + "test: foo\n" + "skip: foo\n" + )) + events = self.to_events(output) + foo = subunit.RemotedTestCase('foo') + self.assertEqual( + [('startTest', foo), + ('addSkip', foo, {}), + ('stopTest', foo)], + events) + + def test_suite(): loader = subunit.tests.TestUtil.TestLoader() result = loader.loadTestsFromName(__name__) |
