summaryrefslogtreecommitdiff
path: root/lib/testtools/testtools/tests/test_content_type.py
diff options
context:
space:
mode:
Diffstat (limited to 'lib/testtools/testtools/tests/test_content_type.py')
-rw-r--r--lib/testtools/testtools/tests/test_content_type.py36
1 files changed, 23 insertions, 13 deletions
diff --git a/lib/testtools/testtools/tests/test_content_type.py b/lib/testtools/testtools/tests/test_content_type.py
index dbefc21dec..d593a14eaf 100644
--- a/lib/testtools/testtools/tests/test_content_type.py
+++ b/lib/testtools/testtools/tests/test_content_type.py
@@ -1,15 +1,11 @@
# Copyright (c) 2008 Jonathan M. Lange. See LICENSE for details.
-import unittest
-from testtools.content_type import ContentType
+from testtools import TestCase
+from testtools.matchers import Equals
+from testtools.content_type import ContentType, UTF8_TEXT
-def test_suite():
- from unittest import TestLoader
- return TestLoader().loadTestsFromName(__name__)
-
-
-class TestContentType(unittest.TestCase):
+class TestContentType(TestCase):
def test___init___None_errors(self):
self.assertRaises(ValueError, ContentType, None, None)
@@ -23,12 +19,26 @@ class TestContentType(unittest.TestCase):
self.assertEqual({}, content_type.parameters)
def test___init___with_parameters(self):
- content_type = ContentType("foo", "bar", {"quux":"thing"})
- self.assertEqual({"quux":"thing"}, content_type.parameters)
+ content_type = ContentType("foo", "bar", {"quux": "thing"})
+ self.assertEqual({"quux": "thing"}, content_type.parameters)
def test___eq__(self):
- content_type1 = ContentType("foo", "bar", {"quux":"thing"})
- content_type2 = ContentType("foo", "bar", {"quux":"thing"})
- content_type3 = ContentType("foo", "bar", {"quux":"thing2"})
+ content_type1 = ContentType("foo", "bar", {"quux": "thing"})
+ content_type2 = ContentType("foo", "bar", {"quux": "thing"})
+ content_type3 = ContentType("foo", "bar", {"quux": "thing2"})
self.assertTrue(content_type1.__eq__(content_type2))
self.assertFalse(content_type1.__eq__(content_type3))
+
+
+class TestBuiltinContentTypes(TestCase):
+
+ def test_plain_text(self):
+ # The UTF8_TEXT content type represents UTF-8 encoded text/plain.
+ self.assertThat(UTF8_TEXT.type, Equals('text'))
+ self.assertThat(UTF8_TEXT.subtype, Equals('plain'))
+ self.assertThat(UTF8_TEXT.parameters, Equals({'charset': 'utf8'}))
+
+
+def test_suite():
+ from unittest import TestLoader
+ return TestLoader().loadTestsFromName(__name__)