def test_encodes_reserved_ascii_characters(self): self.assertEqual(utils.percent_encode(six.u(" !\"#$%&'()")), six.u("%20%21%22%23%24%25%26%27%28%29")) self.assertEqual(utils.percent_encode(six.u("*+,/{|}:;")), six.u("%2A%2B%2C%2F%7B%7C%7D%3A%3B")) self.assertEqual(utils.percent_encode(six.u("<=>?@[\\]^`")), six.u("%3C%3D%3E%3F%40%5B%5C%5D%5E%60"))
def test_encodes_other_non_ascii_characters(self): if six.PY3: original = "支払い" else: original = codecs.lookup('utf-8').decode("支払い")[0] self.assertEqual(utils.percent_encode(original), six.u("%E6%94%AF%E6%89%95%E3%81%84"))
def test_encodes_non_ascii_alpha_characters(self): self.assertEqual(utils.percent_encode(u"å"), u"%C3%A5")
def test_doesnt_encode_unreserved_non_alphanum_chars(self): self.assertEqual(utils.percent_encode(u"-._~"), u"-._~")
def test_doesnt_encode_digits(self): self.assertEqual(utils.percent_encode(u"1234567890"), u"1234567890")
def test_doesnt_encode_uppercase_alpha_characters(self): self.assertEqual(utils.percent_encode(u"ABCXYZ"), u"ABCXYZ")
def test_doesnt_encode_lowercase_alpha_characters(self): self.assertEqual(utils.percent_encode(u"abcxyz"), u"abcxyz")
def test_doesnt_encode_lowercase_alpha_characters(self): self.assertEqual(utils.percent_encode(six.u("abcxyz")), six.u("abcxyz"))
def test_encodes_non_ascii_alpha_characters(self): if six.PY3: original = "å" else: original = codecs.lookup('utf-8').decode("å")[0] self.assertEqual(utils.percent_encode(original), six.u("%C3%A5"))
def test_doesnt_encode_unreserved_non_alphanum_chars(self): self.assertEqual(utils.percent_encode(six.u("-._~")), six.u("-._~"))
def test_doesnt_encode_digits(self): self.assertEqual(utils.percent_encode(six.u("1234567890")), six.u("1234567890"))
def test_doesnt_encode_uppercase_alpha_characters(self): self.assertEqual(utils.percent_encode(six.u("ABCXYZ")), six.u("ABCXYZ"))
def test_encodes_other_non_ascii_characters(self): self.assertEqual(utils.percent_encode(u"支払い"), u"%E6%94%AF%E6%89%95%E3%81%84")
def test_works_with_empty_strings(self): self.assertEqual(utils.percent_encode(u""), u"")
def test_works_with_empty_strings(self): self.assertEqual(utils.percent_encode(six.u("")), six.u(""))