MCPcopy Index your code
hub / github.com/python/cpython / test_default_quoting

Method test_default_quoting

Lib/test/test_urllib.py:858–884  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

856 (expect, result))
857
858 def test_default_quoting(self):
859 # Make sure all characters that should be quoted are by default sans
860 # space (separate test for that).
861 should_quote = [chr(num) for num in range(32)] # For 0x00 - 0x1F
862 should_quote.append(r'<>#%"{}|\^[]`')
863 should_quote.append(chr(127)) # For 0x7F
864 should_quote = ''.join(should_quote)
865 for char in should_quote:
866 result = urllib.parse.quote(char)
867 self.assertEqual(hexescape(char), result,
868 "using quote(): "
869 "%s should be escaped to %s, not %s" %
870 (char, hexescape(char), result))
871 result = urllib.parse.quote_plus(char)
872 self.assertEqual(hexescape(char), result,
873 "using quote_plus(): "
874 "%s should be escapes to %s, not %s" %
875 (char, hexescape(char), result))
876 del should_quote
877 partial_quote = "ab[]cd"
878 expected = "ab%5B%5Dcd"
879 result = urllib.parse.quote(partial_quote)
880 self.assertEqual(expected, result,
881 "using quote(): %r != %r" % (expected, result))
882 result = urllib.parse.quote_plus(partial_quote)
883 self.assertEqual(expected, result,
884 "using quote_plus(): %r != %r" % (expected, result))
885
886 def test_quoting_space(self):
887 # Make sure quote() and quote_plus() handle spaces as specified in

Callers

nothing calls this directly

Calls 5

hexescapeFunction · 0.85
quoteMethod · 0.80
appendMethod · 0.45
joinMethod · 0.45
assertEqualMethod · 0.45

Tested by

no test coverage detected