testtools: Update to latest version.
[metze/samba/wip.git] / lib / testtools / testtools / content_type.py
index aded81b7322a5136a1443bb0434750f3206873c0..c4914088cd73136dbe7fd57c1155d5cd2c5276cb 100644 (file)
@@ -1,4 +1,4 @@
-# Copyright (c) 2009 Jonathan M. Lange. See LICENSE for details.
+# Copyright (c) 2009-2012 testtools developers. See LICENSE for details.
 
 """ContentType - a MIME Content Type."""
 
@@ -27,4 +27,15 @@ class ContentType(object):
         return self.__dict__ == other.__dict__
 
     def __repr__(self):
-        return "%s/%s params=%s" % (self.type, self.subtype, self.parameters)
+        if self.parameters:
+            params = '; '
+            params += ', '.join(
+                sorted('%s="%s"' % (k, v) for k, v in self.parameters.items()))
+        else:
+            params = ''
+        return "%s/%s%s" % (self.type, self.subtype, params)
+
+
+JSON = ContentType('application', 'json')
+
+UTF8_TEXT = ContentType('text', 'plain', {'charset': 'utf8'})