[Python-checkins] cpython (2.7): Issue #12057: Fix .hgeol and test_multibytecodec_support for the conversion of

victor.stinner python-checkins at python.org
Tue May 17 15:50:16 CEST 2011


http://hg.python.org/cpython/rev/83f4c270b27d
changeset:   70178:83f4c270b27d
branch:      2.7
user:        Victor Stinner <victor.stinner at haypocalc.com>
date:        Tue May 17 15:49:56 2011 +0200
summary:
  Issue #12057: Fix .hgeol and test_multibytecodec_support for the conversion of
the CJK encoding testcase BLOB into multiple text files.

files:
  .hgeol                                  |   3 +-
  Lib/test/test_multibytecodec_support.py |  17 +++++++++---
  2 files changed, 14 insertions(+), 6 deletions(-)


diff --git a/.hgeol b/.hgeol
--- a/.hgeol
+++ b/.hgeol
@@ -27,8 +27,9 @@
 **.zip  = BIN
 
 Lib/email/test/data/msg_26.txt = BIN
+Lib/test/cjkencodings/* = BIN
+Lib/test/decimaltestdata/*.decTest = BIN
 Lib/test/sndhdrdata/sndhdr.* = BIN
-Lib/test/decimaltestdata/*.decTest = BIN
 
 # All other files (which presumably are human-editable) are "native".
 # This must be the last rule!
diff --git a/Lib/test/test_multibytecodec_support.py b/Lib/test/test_multibytecodec_support.py
--- a/Lib/test/test_multibytecodec_support.py
+++ b/Lib/test/test_multibytecodec_support.py
@@ -4,8 +4,11 @@
 #   Common Unittest Routines for CJK codecs
 #
 
-import sys, codecs
-import unittest, re
+import codecs
+import os
+import re
+import sys
+import unittest
 from httplib import HTTPException
 from test import test_support
 from StringIO import StringIO
@@ -326,6 +329,10 @@
                 self.fail('Decoding failed while testing %s -> %s: %s' % (
                             repr(csetch), repr(unich), exc.reason))
 
-def load_teststring(encoding):
-    from test import cjkencodings_test
-    return cjkencodings_test.teststring[encoding]
+def load_teststring(name):
+    dir = os.path.join(os.path.dirname(__file__), 'cjkencodings')
+    with open(os.path.join(dir, name + '.txt'), 'rb') as f:
+        encoded = f.read()
+    with open(os.path.join(dir, name + '-utf8.txt'), 'rb') as f:
+        utf8 = f.read()
+    return encoded, utf8

-- 
Repository URL: http://hg.python.org/cpython


More information about the Python-checkins mailing list