Remove unnecessary python path updates for bundled subunit/testtools.
[obnox/samba/samba-obnox.git] / lib / subunit / python / subunit / tests / test_subunit_tags.py
1 #
2 #  subunit: extensions to python unittest to get test results from subprocesses.
3 #  Copyright (C) 2005  Robert Collins <robertc@robertcollins.net>
4 #
5 #  Licensed under either the Apache License, Version 2.0 or the BSD 3-clause
6 #  license at the users choice. A copy of both licenses are available in the
7 #  project source as Apache-2.0 and BSD. You may not use this file except in
8 #  compliance with one of these two licences.
9 #  
10 #  Unless required by applicable law or agreed to in writing, software
11 #  distributed under these licenses is distributed on an "AS IS" BASIS, WITHOUT
12 #  WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
13 #  license you chose for the specific language governing permissions and
14 #  limitations under that license.
15 #
16
17 """Tests for subunit.tag_stream."""
18
19 import unittest
20
21 from testtools.compat import StringIO
22
23 import subunit
24 import subunit.test_results
25
26
27 class TestSubUnitTags(unittest.TestCase):
28
29     def setUp(self):
30         self.original = StringIO()
31         self.filtered = StringIO()
32
33     def test_add_tag(self):
34         self.original.write("tags: foo\n")
35         self.original.write("test: test\n")
36         self.original.write("tags: bar -quux\n")
37         self.original.write("success: test\n")
38         self.original.seek(0)
39         result = subunit.tag_stream(self.original, self.filtered, ["quux"])
40         self.assertEqual([
41             "tags: quux",
42             "tags: foo",
43             "test: test",
44             "tags: bar",
45             "success: test",
46             ],
47             self.filtered.getvalue().splitlines())
48
49     def test_remove_tag(self):
50         self.original.write("tags: foo\n")
51         self.original.write("test: test\n")
52         self.original.write("tags: bar -quux\n")
53         self.original.write("success: test\n")
54         self.original.seek(0)
55         result = subunit.tag_stream(self.original, self.filtered, ["-bar"])
56         self.assertEqual([
57             "tags: -bar",
58             "tags: foo",
59             "test: test",
60             "tags: -quux",
61             "success: test",
62             ],
63             self.filtered.getvalue().splitlines())
64
65
66 def test_suite():
67     loader = subunit.tests.TestUtil.TestLoader()
68     result = loader.loadTestsFromName(__name__)
69     return result