(self)
| 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 |
nothing calls this directly
no test coverage detected