def test_exception_to_unicode_custom(self): # If given custom functions, then we should not mangle c = [ lambda e: converters.to_unicode(e.args[0], encoding='euc_jp'), lambda e: converters.to_unicode(e, encoding='euc_jp') ] tools.eq_( converters.exception_to_unicode(self.exceptions['euc_jpn'], converters=c), self.u_japanese) c.extend(converters.EXCEPTION_CONVERTERS) tools.eq_( converters.exception_to_unicode(self.exceptions['euc_jpn'], converters=c), self.u_japanese) c = [ lambda e: converters.to_unicode(e.args[0], encoding='latin1'), lambda e: converters.to_unicode(e, encoding='latin1') ] tools.eq_( converters.exception_to_unicode(self.exceptions['latin1_spanish'], converters=c), self.u_spanish) c.extend(converters.EXCEPTION_CONVERTERS) tools.eq_( converters.exception_to_unicode(self.exceptions['latin1_spanish'], converters=c), self.u_spanish)
def test_exception_to_unicode_with_bytes(self): tools.eq_(converters.exception_to_unicode(self.exceptions['utf8_jpn']), self.u_japanese) tools.eq_(converters.exception_to_unicode(self.exceptions['utf8_spanish']), self.u_spanish) # Mangled latin1/utf8 conversion but no tracebacks tools.eq_(converters.exception_to_unicode(self.exceptions['latin1_spanish']), self.u_mangled_spanish_latin1_as_utf8) # Mangled euc_jp/utf8 conversion but no tracebacks tools.eq_(converters.exception_to_unicode(self.exceptions['euc_jpn']), self.u_mangled_euc_jp_as_utf8)
def test_exception_to_unicode_with_bytes(self): tools.eq_(converters.exception_to_unicode(self.exceptions['utf8_jpn']), self.u_japanese) tools.eq_( converters.exception_to_unicode(self.exceptions['utf8_spanish']), self.u_spanish) # Mangled latin1/utf8 conversion but no tracebacks tools.eq_( converters.exception_to_unicode(self.exceptions['latin1_spanish']), self.u_mangled_spanish_latin1_as_utf8) # Mangled euc_jp/utf8 conversion but no tracebacks tools.eq_(converters.exception_to_unicode(self.exceptions['euc_jpn']), self.u_mangled_euc_jp_as_utf8)
def test_exception_to_unicode_custom(self): # If given custom functions, then we should not mangle c = [lambda e: converters.to_unicode(e, encoding='euc_jp')] tools.ok_(converters.exception_to_unicode(self.exceptions['euc_jpn'], converters=c) == self.u_japanese) c.extend(converters.EXCEPTION_CONVERTERS) tools.ok_(converters.exception_to_unicode(self.exceptions['euc_jpn'], converters=c) == self.u_japanese) c = [lambda e: converters.to_unicode(e, encoding='latin1')] tools.ok_(converters.exception_to_unicode(self.exceptions['latin1_spanish'], converters=c) == self.u_spanish) c.extend(converters.EXCEPTION_CONVERTERS) tools.ok_(converters.exception_to_unicode(self.exceptions['latin1_spanish'], converters=c) == self.u_spanish)
def test_exception_to_unicode_with_unicode(self): tools.eq_(converters.exception_to_unicode(self.exceptions['u_jpn']), self.u_japanese) tools.eq_( converters.exception_to_unicode(self.exceptions['u_spanish']), self.u_spanish)
def test_exception_to_unicode_with_unicode(self): tools.eq_(converters.exception_to_unicode(self.exceptions['u_jpn']), self.u_japanese) tools.eq_(converters.exception_to_unicode(self.exceptions['u_spanish']), self.u_spanish)