예제 #1
0
 def test_error_sanitizing(self):
     # ASCII str
     self.assertEqual(exec_utils._safe_unicode(ValueError("foo")), "foo")
     # UTF-8 encoded str
     self.assertEqual(exec_utils._safe_unicode(ValueError(u"crème".encode("utf-8"))), u"cr\xe8me")
     # Unicode obj
     self.assertEqual(exec_utils._safe_unicode(ValueError(u"brûlée")), u"br\xfbl\xe9e")
     # Not UTF-8
     self.assertEqual(exec_utils._safe_unicode(ValueError(u"Invalid read name: DÑÁnèxûs".encode("ISO-8859-1"))),
                      "Invalid read name: D??n?x?s [Raw error message: 496e76616c69642072656164206e616d653a2044d1c16ee878fb73]")
예제 #2
0
 def test_error_sanitizing(self):
     # ASCII str
     self.assertEqual(exec_utils._safe_unicode(ValueError("foo")), "foo")
     # UTF-8 encoded str
     self.assertEqual(exec_utils._safe_unicode(ValueError("crème".encode("utf-8"))),
                      "cr\xe8me" if USING_PYTHON2 else "b'cr\\xc3\\xa8me'")
     # Unicode obj
     self.assertEqual(exec_utils._safe_unicode(ValueError("brûlée")), "br\xfbl\xe9e")
     # Not UTF-8
     if USING_PYTHON2:
         expected = "Invalid read name: D??n?x?s [Raw error message: 496e76616c69642072656164206e616d653a2044d1c16ee878fb73]"
     else:
         expected = "b'Invalid read name: D\\xd1\\xc1n\\xe8x\\xfbs'"
     self.assertEqual(exec_utils._safe_unicode(ValueError("Invalid read name: DÑÁnèxûs".encode("ISO-8859-1"))), expected)
예제 #3
0
 def test_error_sanitizing(self):
     # ASCII str
     self.assertEqual(exec_utils._safe_unicode(ValueError("foo")), "foo")
     # UTF-8 encoded str
     self.assertEqual(exec_utils._safe_unicode(ValueError("crème".encode("utf-8"))),
                      "cr\xe8me" if USING_PYTHON2 else "b'cr\\xc3\\xa8me'")
     # Unicode obj
     self.assertEqual(exec_utils._safe_unicode(ValueError("brûlée")), "br\xfbl\xe9e")
     # Not UTF-8
     if USING_PYTHON2:
         expected = "Invalid read name: D??n?x?s [Raw error message: 496e76616c69642072656164206e616d653a2044d1c16ee878fb73]"
     else:
         expected = "b'Invalid read name: D\\xd1\\xc1n\\xe8x\\xfbs'"
     self.assertEqual(exec_utils._safe_unicode(ValueError("Invalid read name: DÑÁnèxûs".encode("ISO-8859-1"))), expected)
예제 #4
0
 def test_error_sanitizing(self):
     # ASCII str
     self.assertEqual(exec_utils._safe_unicode(ValueError("foo")), "foo")
     # UTF-8 encoded str
     self.assertEqual(
         exec_utils._safe_unicode(ValueError(u"crème".encode("utf-8"))),
         u"cr\xe8me")
     # Unicode obj
     self.assertEqual(exec_utils._safe_unicode(ValueError(u"brûlée")),
                      u"br\xfbl\xe9e")
     # Not UTF-8
     self.assertEqual(
         exec_utils._safe_unicode(
             ValueError(
                 u"Invalid read name: DÑÁnèxûs".encode("ISO-8859-1"))),
         "Invalid read name: D??n?x?s [Raw error message: 496e76616c69642072656164206e616d653a2044d1c16ee878fb73]"
     )