def test_streamwriter(self): # We can't test with the real utf-8 StreamReader here. # The standard SR.readline{,s} are mostly broken for multibyte seqs. # UTF8Reader = codecs.lookup('utf-8')[2] UTF8Reader = iconv_codec.lookup("utf-8")[2] for name in ["read", "readline", "readlines"]: for sizehint in [None, -1] + range(1, 33) + [64, 128, 256, 512, 1024]: istream = UTF8Reader(StringIO(self.tstring[1])) ostream = self.writer(StringIO()) func = getattr(istream, name) while 1: data = func(sizehint) if not data: break if name == "readlines": ostream.writelines(data) else: ostream.write(data) self.assertEqual(ostream.getvalue(), self.tstring[0])
def test_main(): if not iconv_codec.lookup("euc-kr"): raise test_support.TestSkipped("your iconv doesn't have a support for euc-kr encoding") suite = unittest.TestSuite() suite.addTest(unittest.makeSuite(Test_EUC_KR)) test_support.run_suite(suite)