def test_ignored_codecs_are_identical_to_standard_library(self): def encoded(code, codec): if _IS_PYTHON2: result = unicode(chr(code), codec.name, errors='replace') else: result = chr(code).encode(codec.name, errors='replace') for codec_name in ebcdic.ignored_codec_names(): ebcdic_codec = ebcdic.lookup(codec_name) self.assertNotEqual(ebcdic_codec, None, codec_name) standard_codec = codecs.lookup(codec_name) self.assertNotEqual(standard_codec, None, codec_name) for code in range(256): ebcdic_char = encoded(code, ebcdic_codec) standard_char = encoded(code, standard_codec) self.assertEqual(ebcdic_char, standard_char, '%s at %d: %r != %r' % (codec_name, code, ebcdic_char, standard_char))
def test_ignored_codecs_are_identical_to_standard_library(self): def encoded(code, codec): if _IS_PYTHON2: result = unicode(chr(code), codec.name, errors='replace') else: result = chr(code).encode(codec.name, errors='replace') for codec_name in ebcdic.ignored_codec_names(): ebcdic_codec = ebcdic.lookup(codec_name) self.assertNotEqual(ebcdic_codec, None, codec_name) standard_codec = codecs.lookup(codec_name) self.assertNotEqual(standard_codec, None, codec_name) for code in range(256): ebcdic_char = encoded(code, ebcdic_codec) standard_char = encoded(code, standard_codec) self.assertEqual( ebcdic_char, standard_char, '%s at %d: %r != %r' % (codec_name, code, ebcdic_char, standard_char))
def test_can_lookup_ebcdic_codec(self): ebcdic_cp500 = ebcdic.lookup('cp500') standard_cp500 = codecs.lookup('cp500') self.assertNotEqual(ebcdic_cp500, standard_cp500)