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")
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")
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),))