Beispiel #1
0
 def test_generateKeyValuesNone(self):
     """
     L{generateKeyValues} accepts C{None} as the 2nd element of a tuple and
     includes just the 1st element in the output without an C{"="}.
     """
     self.assertEqual(
         generateKeyValues([("foo", None), ("bar", "baz")]),
         "foo;bar=baz")
Beispiel #2
0
 def test_generateKeyValues(self):
     """
     L{generateKeyValues} accepts an iterable of parameters and returns a
     string formatted according to RFC 2045 section 5.1.
     """
     self.assertEqual(
         generateKeyValues(iter([("foo", "bar"), ("baz", "quux")])),
         "foo=bar;baz=quux")
Beispiel #3
0
 def test_generateKeyValuesQuoting(self):
     """
     L{generateKeyValues} quotes the value of the 2nd element of a tuple if
     it includes a character which cannot be in an HTTP token as defined in
     RFC 2616 section 2.2.
     """
     for needsQuote in [' ', '\t', '(', ')', '<', '>', '@', ',', ';', ':',
                        '\\', '"', '/', '[', ']', '?', '=', '{', '}']:
         self.assertEqual(
             generateKeyValues([("foo", needsQuote)]),
             'foo=%s' % (quoteString(needsQuote),))