diff options
| -rw-r--r-- | README | 10 | ||||
| -rwxr-xr-x | filters/subunit-stats | 4 | ||||
| -rwxr-xr-x | filters/subunit-tags | 2 | ||||
| -rwxr-xr-x | filters/subunit2pyunit | 2 | ||||
| -rwxr-xr-x | filters/tap2subunit | 8 | ||||
| -rw-r--r-- | python/subunit/__init__.py | 9 | ||||
| -rw-r--r-- | python/subunit/tests/test_tap2subunit.py | 16 |
7 files changed, 29 insertions, 22 deletions
@@ -29,10 +29,10 @@ Subunit comes in three parts: * Protocol readers (servers) * Filters -The reader component acts as a test suite in the language that it is written +A reader component acts as a test suite in the language that it is written for. Currently subunit only provides a Python protocol reader. -Writers are used to output test results in subunit form. Writers are typically +Writers output test results in subunit form. Writers are typically test suite runners or test suite result objects in specific languages. Currently subunit provides writers for Python, C, C++, and shell. @@ -43,7 +43,7 @@ stream on-the-fly. Currently subunit provides: * subunit-stats - generate a summary of a subunit stream. * subunit-tags - add or remove tags from a stream. -The subunit code is organised at the top level by directories, for language +The subunit code is organised at the top level by directories for language bindings, and additionally the filters directory for filters. Using subunit in Python @@ -200,10 +200,10 @@ The time element acts as a clock event - it sets the time for all future events. Currently this is not exposed at the python API layer. The skip result is used to indicate a test that was found by the runner but not -[fully] executed due to some policy or dependency issue. Currently this is +fully executed due to some policy or dependency issue. Currently this is represented in Python as a successful test. The xfail result is used to indicate a test that was expected to fail failing -in the expected manner. As this is a normal condition [for such tests] it is +in the expected manner. As this is a normal condition for such tests it is represented as a successful test in Python. In future, skip and xfail results will be represented semantically in Python, but some discussion is underway on the right way to do this. diff --git a/filters/subunit-stats b/filters/subunit-stats index ad16052..4778b80 100755 --- a/filters/subunit-stats +++ b/filters/subunit-stats @@ -1,6 +1,6 @@ #!/usr/bin/env python # subunit: extensions to python unittest to get test results from subprocesses. -# Copyright (C) 2008 Robert Collins <robertc@robertcollins.net> +# Copyright (C) 2009 Robert Collins <robertc@robertcollins.net> # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -17,7 +17,7 @@ # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # -"""Filter a subunit stream to get aggregate satistics.""" +"""Filter a subunit stream to get aggregate statistics.""" import sys import unittest diff --git a/filters/subunit-tags b/filters/subunit-tags index acd6150..10651e1 100755 --- a/filters/subunit-tags +++ b/filters/subunit-tags @@ -1,6 +1,6 @@ #!/usr/bin/env python # subunit: extensions to python unittest to get test results from subprocesses. -# Copyright (C) 2005 Robert Collins <robertc@robertcollins.net> +# Copyright (C) 2009 Robert Collins <robertc@robertcollins.net> # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by diff --git a/filters/subunit2pyunit b/filters/subunit2pyunit index 98af05b..e70bf51 100755 --- a/filters/subunit2pyunit +++ b/filters/subunit2pyunit @@ -1,6 +1,6 @@ #!/usr/bin/env python # subunit: extensions to python unittest to get test results from subprocesses. -# Copyright (C) 2008 Robert Collins <robertc@robertcollins.net> +# Copyright (C) 2009 Robert Collins <robertc@robertcollins.net> # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by diff --git a/filters/tap2subunit b/filters/tap2subunit index e41af8e..9c49d25 100755 --- a/filters/tap2subunit +++ b/filters/tap2subunit @@ -1,6 +1,6 @@ #!/usr/bin/env python # subunit: extensions to python unittest to get test results from subprocesses. -# Copyright (C) 2005 Robert Collins <robertc@robertcollins.net> +# Copyright (C) 2009 Robert Collins <robertc@robertcollins.net> # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -17,7 +17,11 @@ # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # -"""A filter that reads a TAP stream and outputs a subunit stream.""" +"""A filter that reads a TAP stream and outputs a subunit stream. + +More information on TAP is available at +http://testanything.org/wiki/index.php/Main_Page. +""" import sys diff --git a/python/subunit/__init__.py b/python/subunit/__init__.py index ce34b0f..f63a3a0 100644 --- a/python/subunit/__init__.py +++ b/python/subunit/__init__.py @@ -523,13 +523,11 @@ def TAP2SubUnit(tap, subunit): subunit.write("]\n") continue # not a plan line, or have seen one before - #match = re.match("(ok|not ok)\s+(\d+)?\s*([^#]*)\s*(?:#\s+(.*))\n", line) match = re.match("(ok|not ok)(?:\s+(\d+)?)?(?:\s+([^#]*[^#\s]+)\s*)?(?:\s+#\s+(TODO|SKIP)(?:\s+(.*))?)?\n", line) if match: # new test, emit current one. _emit_test() status, number, description, directive, directive_comment = match.groups() - # status, number, description = match.groups() if status == 'ok': result = 'success' else: @@ -583,11 +581,13 @@ def tag_stream(original, filtered, tags): :param filtered: The output stream. :param tags: The tags to apply. As in a normal stream - a list of 'TAG' or '-TAG' commands. + A 'TAG' command will add the tag to the output stream, and override any existing '-TAG' command in that stream. Specifically: * A global 'tags: TAG' will be added to the start of the stream. * Any tags commands with -TAG will have the -TAG removed. + A '-TAG' command will remove the TAG command from the stream. Specifically: * A 'tags: -TAG' command will be added to the start of the stream. @@ -629,7 +629,8 @@ class ProtocolTestCase(object): return self.run(result) def run(self, result=None): - if result is None: result = self.defaultTestResult() + if result is None: + result = self.defaultTestResult() protocol = TestProtocolServer(result) for line in self._stream: protocol.lineReceived(line) @@ -678,5 +679,5 @@ class TestResultStats(unittest.TestResult): self.tags.update(test.tags) def wasSuccessful(self): - "Tells whether or not this result was a success" + """Tells whether or not this result was a success""" return self.failed_tests == 0 diff --git a/python/subunit/tests/test_tap2subunit.py b/python/subunit/tests/test_tap2subunit.py index 7e59985..bc6bf14 100644 --- a/python/subunit/tests/test_tap2subunit.py +++ b/python/subunit/tests/test_tap2subunit.py @@ -59,7 +59,9 @@ class TestTAP2SubUnit(unittest.TestCase): def test_ok_test_pass(self): # A file # ok - # results in a passed test with name 'test 1' + # results in a passed test with name 'test 1' (a synthetic name as tap + # does not require named fixtures - it is the first test in the tap + # stream). self.tap.write("ok\n") self.tap.seek(0) result = subunit.TAP2SubUnit(self.tap, self.subunit) @@ -284,7 +286,7 @@ class TestTAP2SubUnit(unittest.TestCase): # not ok 4 - fourth # 1..4 # results in four tests numbered and named - self.tap.write('ok 1 - first test in a script with no plan at all\n') + self.tap.write('ok 1 - first test in a script with trailing plan\n') self.tap.write('not ok 2 - second\n') self.tap.write('ok 3 - third\n') self.tap.write('not ok 4 - fourth\n') @@ -293,8 +295,8 @@ class TestTAP2SubUnit(unittest.TestCase): result = subunit.TAP2SubUnit(self.tap, self.subunit) self.assertEqual(0, result) self.assertEqual([ - 'test test 1 - first test in a script with no plan at all', - 'success test 1 - first test in a script with no plan at all', + 'test test 1 - first test in a script with trailing plan', + 'success test 1 - first test in a script with trailing plan', 'test test 2 - second', 'failure test 2 - second', 'test test 3 - third', @@ -313,7 +315,7 @@ class TestTAP2SubUnit(unittest.TestCase): # not ok 4 - fourth # results in four tests numbered and named self.tap.write('1..4\n') - self.tap.write('ok 1 - first test in a script with no plan at all\n') + self.tap.write('ok 1 - first test in a script with a plan\n') self.tap.write('not ok 2 - second\n') self.tap.write('ok 3 - third\n') self.tap.write('not ok 4 - fourth\n') @@ -321,8 +323,8 @@ class TestTAP2SubUnit(unittest.TestCase): result = subunit.TAP2SubUnit(self.tap, self.subunit) self.assertEqual(0, result) self.assertEqual([ - 'test test 1 - first test in a script with no plan at all', - 'success test 1 - first test in a script with no plan at all', + 'test test 1 - first test in a script with a plan', + 'success test 1 - first test in a script with a plan', 'test test 2 - second', 'failure test 2 - second', 'test test 3 - third', |
