Run all tests
[third_party/subunit] / python / subunit / tests / test_content_type.py
1 #
2 #  subunit: extensions to Python unittest to get test results from subprocesses.
3 #  Copyright (C) 2009  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 import unittest
18 import subunit
19 from subunit.content_type import ContentType
20
21
22 def test_suite():
23     loader = subunit.tests.TestUtil.TestLoader()
24     result = loader.loadTestsFromName(__name__)
25     return result
26
27
28 class TestContentType(unittest.TestCase):
29
30     def test___init___None_errors(self):
31         self.assertRaises(ValueError, ContentType, None, None)
32         self.assertRaises(ValueError, ContentType, None, "traceback")
33         self.assertRaises(ValueError, ContentType, "text", None)
34
35     def test___init___sets_ivars(self):
36         content_type = ContentType("foo", "bar")
37         self.assertEqual("foo", content_type.type)
38         self.assertEqual("bar", content_type.subtype)
39         self.assertEqual({}, content_type.parameters)
40
41     def test___init___with_parameters(self):
42         content_type = ContentType("foo", "bar", {"quux":"thing"})
43         self.assertEqual({"quux":"thing"}, content_type.parameters)
44
45     def test___eq__(self):
46         content_type1 = ContentType("foo", "bar", {"quux":"thing"})
47         content_type2 = ContentType("foo", "bar", {"quux":"thing"})
48         content_type3 = ContentType("foo", "bar", {"quux":"thing2"})
49         self.assertTrue(content_type1.__eq__(content_type2))
50         self.assertFalse(content_type1.__eq__(content_type3))