[Zope3-checkins] SVN: Zope3/trunk/src/zope/publisher/ remove the cosmetic space join() inserts between the "; " and parameter name;

Fred L. Drake, Jr. fdrake at gmail.com
Mon Aug 1 10:51:54 EDT 2005


Log message for revision 37618:
  remove the cosmetic space join() inserts between the ";" and parameter name;
  this makes it easier to integrate without making spurious changes to
  existing tests
  

Changed:
  U   Zope3/trunk/src/zope/publisher/contenttype.py
  U   Zope3/trunk/src/zope/publisher/tests/test_contenttype.py

-=-
Modified: Zope3/trunk/src/zope/publisher/contenttype.py
===================================================================
--- Zope3/trunk/src/zope/publisher/contenttype.py	2005-08-01 14:22:12 UTC (rev 37617)
+++ Zope3/trunk/src/zope/publisher/contenttype.py	2005-08-01 14:51:53 UTC (rev 37618)
@@ -41,7 +41,7 @@
         type = string
         params = []
     if "/" not in type:
-        raise ValueError("content type missing major/minor parts")
+        raise ValueError("content type missing major/minor parts: %r" % type)
     type = type.strip()
 
     major, minor = type.lower().split("/", 1)
@@ -123,7 +123,7 @@
         # ensure a predictable order:
         params.sort()
     for name, value in params:
-        pstr += "; %s=%s" % (name, _escape(value))
+        pstr += ";%s=%s" % (name, _escape(value))
     return "%s/%s%s" % (major, minor, pstr)
 
 def _escape(string):

Modified: Zope3/trunk/src/zope/publisher/tests/test_contenttype.py
===================================================================
--- Zope3/trunk/src/zope/publisher/tests/test_contenttype.py	2005-08-01 14:22:12 UTC (rev 37617)
+++ Zope3/trunk/src/zope/publisher/tests/test_contenttype.py	2005-08-01 14:51:53 UTC (rev 37618)
@@ -139,54 +139,54 @@
     def test_single_token_param(self):
         self.assertEqual(
             contenttype.join(("text", "plain", [("charset", "UTF-8")])),
-            "text/plain; charset=UTF-8")
+            "text/plain;charset=UTF-8")
         self.assertEqual(
             contenttype.join(("text", "plain", {"charset": "UTF-8"})),
-            "text/plain; charset=UTF-8")
+            "text/plain;charset=UTF-8")
 
     def test_multi_params_list_maintains_order(self):
         # multiple parameters given as a list maintain order:
         self.assertEqual(
             contenttype.join(("text", "plain",
                               [("charset", "UTF-8"), ("format", "flowed")])),
-            "text/plain; charset=UTF-8; format=flowed")
+            "text/plain;charset=UTF-8;format=flowed")
         self.assertEqual(
             contenttype.join(("text", "plain",
                               [("format", "flowed"), ("charset", "UTF-8")])),
-            "text/plain; format=flowed; charset=UTF-8")
+            "text/plain;format=flowed;charset=UTF-8")
 
     def test_multi_params_dict_sorted_order(self):
         # multiple parameters given as a dict are sorted by param name:
         self.assertEqual(
             contenttype.join(("text", "plain",
                               {"charset": "UTF-8", "format": "flowed"})),
-            "text/plain; charset=UTF-8; format=flowed")
+            "text/plain;charset=UTF-8;format=flowed")
 
     def test_params_list_quoted(self):
         # parameter values are quoted automatically:
         self.assertEqual(contenttype.join(("a", "b", [("c", "")])),
-                         'a/b; c=""')
+                         'a/b;c=""')
         self.assertEqual(contenttype.join(("a", "b", [("c", "ab cd")])),
-                         'a/b; c="ab cd"')
+                         'a/b;c="ab cd"')
         self.assertEqual(contenttype.join(("a", "b", [("c", " \t")])),
-                         'a/b; c=" \t"')
+                         'a/b;c=" \t"')
         self.assertEqual(contenttype.join(("a", "b", [("c", '"')])),
-                         r'a/b; c="\""')
+                         r'a/b;c="\""')
         self.assertEqual(contenttype.join(("a", "b", [("c", "\n")])),
-                         'a/b; c="\\\n"')
+                         'a/b;c="\\\n"')
 
     def test_params_dict_quoted(self):
         # parameter values are quoted automatically:
         self.assertEqual(contenttype.join(("a", "b", {"c": ""})),
-                         'a/b; c=""')
+                         'a/b;c=""')
         self.assertEqual(contenttype.join(("a", "b", {"c": "ab cd"})),
-                         'a/b; c="ab cd"')
+                         'a/b;c="ab cd"')
         self.assertEqual(contenttype.join(("a", "b", {"c": " \t"})),
-                         'a/b; c=" \t"')
+                         'a/b;c=" \t"')
         self.assertEqual(contenttype.join(("a", "b", {"c": '"'})),
-                         r'a/b; c="\""')
+                         r'a/b;c="\""')
         self.assertEqual(contenttype.join(("a", "b", {"c": "\n"})),
-                         'a/b; c="\\\n"')
+                         'a/b;c="\\\n"')
 
 
 def test_suite():



More information about the Zope3-Checkins mailing list