def test_quoteString(self):
     """
     L{quoteString} returns a string which when interpreted according to the
     rules for I{quoted-string} (RFC 2616 section 2.2) matches the input
     string.
     """
     self.assertEqual(
         quoteString('a\\b"c'),
         '"a\\\\b\\"c"')
 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),))