diff options
| author | Robert Collins <robertc@robertcollins.net> | 2008-12-08 18:02:15 +1100 |
|---|---|---|
| committer | Robert Collins <robertc@robertcollins.net> | 2008-12-08 18:02:15 +1100 |
| commit | 0ed5a16cc89aef319cfc2d4bb66c1ac1ced10f5f (patch) | |
| tree | aacbc7251c1446466c3d33e5d2c25524fb7de070 /python/subunit/tests | |
| parent | 852b598c58186f44178fa78f80f54faf98168101 (diff) | |
| download | subunit-git-0ed5a16cc89aef319cfc2d4bb66c1ac1ced10f5f.tar.gz | |
Add subunit-tags to alter the tags on a test stream.
Diffstat (limited to 'python/subunit/tests')
| -rw-r--r-- | python/subunit/tests/__init__.py | 2 | ||||
| -rw-r--r-- | python/subunit/tests/test_subunit_tags.py | 70 |
2 files changed, 72 insertions, 0 deletions
diff --git a/python/subunit/tests/__init__.py b/python/subunit/tests/__init__.py index 7f501c7..6703514 100644 --- a/python/subunit/tests/__init__.py +++ b/python/subunit/tests/__init__.py @@ -19,6 +19,7 @@ from subunit.tests import ( TestUtil, + test_subunit_tags, test_tap2subunit, test_test_protocol, ) @@ -27,4 +28,5 @@ def test_suite(): result = TestUtil.TestSuite() result.addTest(test_test_protocol.test_suite()) result.addTest(test_tap2subunit.test_suite()) + result.addTest(test_subunit_tags.test_suite()) return result diff --git a/python/subunit/tests/test_subunit_tags.py b/python/subunit/tests/test_subunit_tags.py new file mode 100644 index 0000000..66cff68 --- /dev/null +++ b/python/subunit/tests/test_subunit_tags.py @@ -0,0 +1,70 @@ +# +# subunit: extensions to python unittest to get test results from subprocesses. +# Copyright (C) 2005 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 +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# + +"""Tests for subunit.tag_stream.""" + +import unittest +from StringIO import StringIO + +import subunit + + +class TestSubUnitTags(unittest.TestCase): + + def setUp(self): + self.original = StringIO() + self.filtered = StringIO() + + def test_add_tag(self): + self.original.write("tags: foo\n") + self.original.write("test: test\n") + self.original.write("tags: bar -quux\n") + self.original.write("success: test\n") + self.original.seek(0) + result = subunit.tag_stream(self.original, self.filtered, ["quux"]) + self.assertEqual([ + "tags: quux", + "tags: foo", + "test: test", + "tags: bar", + "success: test", + ], + self.filtered.getvalue().splitlines()) + + def test_remove_tag(self): + self.original.write("tags: foo\n") + self.original.write("test: test\n") + self.original.write("tags: bar -quux\n") + self.original.write("success: test\n") + self.original.seek(0) + result = subunit.tag_stream(self.original, self.filtered, ["-bar"]) + self.assertEqual([ + "tags: -bar", + "tags: foo", + "test: test", + "tags: -quux", + "success: test", + ], + self.filtered.getvalue().splitlines()) + + +def test_suite(): + loader = subunit.tests.TestUtil.TestLoader() + result = loader.loadTestsFromName(__name__) + return result |
