Example #1
0
 def test_utf8_strings_untouched(self):
     # already utf-8-encoded strings are left untouched.
     # LATIN SMALL LETTER A WITH DIAERESIS
     self.assertEqual(upload._encode_as_utf8({'k': '\xc3\xa4'}),
                      {'k': '\xc3\xa4'})
     # EURO SIGN
     self.assertEqual(upload._encode_as_utf8({'k': '\xe2\x82\xac'}),
                      {'k': '\xe2\x82\xac'})
Example #2
0
 def test_latin1_replaced_by_utf8_chars(self):
     # contained latin1-chars are replaced by utf-8 encoded ones
     # LATIN SMALL LETTER A WITH DIAERESIS
     self.assertEqual(upload._encode_as_utf8({"k": "\xe4"}),
                      {"k": "\xef\xbf\xbd"})
Example #3
0
 def test_non_strings_untouched(self):
     # non-string values are left untouched
     self.assertEqual(upload._encode_as_utf8({'k': 1}), {'k': 1})
     self.assertEqual(upload._encode_as_utf8({'k': 1.0}), {'k': 1.0})
     self.assertEqual(upload._encode_as_utf8({'k': u'val'}), {'k': u'val'})
Example #4
0
 def test_regular_ascii_untouched(self):
     # regular ASCII strings are left untouched
     self.assertEqual(upload._encode_as_utf8({'k': 'val'}), {'k': 'val'})
Example #5
0
 def test_latin1_replaced_by_utf8_chars(self):
     # contained latin1-chars are replaced by utf-8 encoded ones
     # LATIN SMALL LETTER A WITH DIAERESIS
     self.assertEqual(upload._encode_as_utf8({"k": "\xe4"}), {"k": "\xef\xbf\xbd"})
Example #6
0
 def test_utf8_strings_untouched(self):
     # already utf-8-encoded strings are left untouched.
     # LATIN SMALL LETTER A WITH DIAERESIS
     self.assertEqual(upload._encode_as_utf8({'k': '\xc3\xa4'}), {'k': '\xc3\xa4'})
     # EURO SIGN
     self.assertEqual(upload._encode_as_utf8({'k': '\xe2\x82\xac'}), {'k': '\xe2\x82\xac'})
Example #7
0
 def test_non_strings_untouched(self):
     # non-string values are left untouched
     self.assertEqual(upload._encode_as_utf8({'k': 1}), {'k': 1})
     self.assertEqual(upload._encode_as_utf8({'k': 1.0}), {'k': 1.0})
     self.assertEqual(upload._encode_as_utf8({'k': u'val'}), {'k': u'val'})
Example #8
0
 def test_regular_ascii_untouched(self):
     # regular ASCII strings are left untouched
     self.assertEqual(upload._encode_as_utf8({'k': 'val'}), {'k': 'val'})