Rename checks for test_support.have_unicode (we always

have unicode support now) and either drop the tests or
merge them into the existing tests.
This commit is contained in:
Walter Dörwald 2007-06-08 14:30:53 +00:00
parent 0157ebe999
commit 9b775535f8
7 changed files with 62 additions and 112 deletions

View File

@ -7,8 +7,7 @@ except ImportError:
import pickletools
import copy_reg
from test.test_support import TestFailed, have_unicode, TESTFN, \
run_with_locale
from test.test_support import TestFailed, TESTFN, run_with_locale
# Tests that try a number of pickle protocols should have a
# for proto in protocols:
@ -482,10 +481,8 @@ class AbstractPickleTests(unittest.TestCase):
buf = b"S" + bytes(s) + b"\012p0\012."
self.assertRaises(ValueError, self.loads, buf)
if have_unicode:
def test_unicode(self):
endcases = [str(''), str('<\\u>'), str('<\\\u1234>'),
str('<\n>'), str('<\\>')]
endcases = ['', '<\\u>', '<\\\u1234>', '<\n>', '<\\>']
for proto in protocols:
for u in endcases:
p = self.dumps(u, proto)

View File

@ -1100,7 +1100,6 @@ class MixinStrUserStringTest:
# Additional tests that only work with
# 8bit compatible object, i.e. str and UserString
if test_support.have_unicode:
def test_encoding_decoding(self):
codecs = [('rot13', b'uryyb jbeyq'),
('base64', b'aGVsbG8gd29ybGQ=\n'),

View File

@ -121,8 +121,6 @@ class BinASCIITest(unittest.TestCase):
self.assertRaises(binascii.Error, binascii.a2b_hex, t[:-1])
self.assertRaises(binascii.Error, binascii.a2b_hex, t[:-1] + b'q')
# Verify the treatment of Unicode strings
if test_support.have_unicode:
self.assertEqual(binascii.hexlify('a'), b'61')
def test_qp(self):

View File

@ -146,18 +146,11 @@ elif os.name == 'riscos':
TESTFN = 'testfile'
else:
TESTFN = '@test'
# Unicode name only used if TEST_FN_ENCODING exists for the platform.
if have_unicode:
# Assuming sys.getfilesystemencoding()!=sys.getdefaultencoding()
# TESTFN_UNICODE is a filename that can be encoded using the
# file system encoding, but *not* with the default (ascii) encoding
if isinstance('', str):
# python -U
# XXX perhaps unicode() should accept Unicode strings?
TESTFN_UNICODE = "@test-\xe0\xf2"
else:
# 2 latin characters.
TESTFN_UNICODE = str("@test-\xe0\xf2", "latin-1")
TESTFN_ENCODING = sys.getfilesystemencoding()
# TESTFN_UNICODE_UNENCODEABLE is a filename that should *not* be
# able to be encoded by *either* the default or filesystem encoding.
@ -168,7 +161,7 @@ else:
TESTFN_UNICODE_UNENCODEABLE = None
else:
# Japanese characters (I think - from bug 846133)
TESTFN_UNICODE_UNENCODEABLE = eval('u"@test-\u5171\u6709\u3055\u308c\u308b"')
TESTFN_UNICODE_UNENCODEABLE = "@test-\u5171\u6709\u3055\u308c\u308b"
try:
# XXX - Note - should be using TESTFN_ENCODING here - but for
# Windows, "mbcs" currently always operates as if in

View File

@ -336,19 +336,6 @@ What a mess!
"with ", "much white", "space."],
drop_whitespace=False)
if test_support.have_unicode:
def test_unicode(self):
# *Very* simple test of wrapping Unicode strings. I'm sure
# there's more to it than this, but let's at least make
# sure textwrap doesn't crash on Unicode input!
text = "Hello there, how are you today?"
self.check_wrap(text, 50, ["Hello there, how are you today?"])
self.check_wrap(text, 20, ["Hello there, how are", "you today?"])
olines = self.wrapper.wrap(text)
assert isinstance(olines, list) and isinstance(olines[0], str)
otext = self.wrapper.fill(text)
assert isinstance(otext, str)
def test_split(self):
# Ensure that the standard _split() method works as advertised
# in the comments

View File

@ -1,6 +1,6 @@
# Python test set -- part 6, built-in types
from test.test_support import run_unittest, have_unicode
from test.test_support import run_unittest
import unittest
import sys
@ -199,19 +199,6 @@ class TypesTests(unittest.TestCase):
self.assertEqual(a[100:-100:-1], a[::-1])
self.assertEqual(a[-100:100:2], '02468')
if have_unicode:
a = str(b'0123456789', 'ascii')
self.assertEqual(a[::], a)
self.assertEqual(a[::2], str(b'02468', 'ascii'))
self.assertEqual(a[1::2], str(b'13579', 'ascii'))
self.assertEqual(a[::-1], str(b'9876543210', 'ascii'))
self.assertEqual(a[::-2], str(b'97531', 'ascii'))
self.assertEqual(a[3::-2], str(b'31', 'ascii'))
self.assertEqual(a[-100:100:], a)
self.assertEqual(a[100:-100:-1], a[::-1])
self.assertEqual(a[-100:100:2], str(b'02468', 'ascii'))
def test_type_function(self):
self.assertRaises(TypeError, type, 1, 2)
self.assertRaises(TypeError, type, 1, 2, 3, 4)

View File

@ -4,13 +4,6 @@ import unittest
import xmlrpclib
from test import test_support
try:
str
except NameError:
have_unicode = False
else:
have_unicode = True
alist = [{'astring': 'foo@bar.baz.spam',
'afloat': 7283.43,
'anint': 2**20,
@ -147,15 +140,11 @@ class XMLRPCTestCase(unittest.TestCase):
del sys.setdefaultencoding
items = list(d.items())
if have_unicode:
self.assertEquals(s, "abc \x95")
self.assert_(isinstance(s, str))
self.assertEquals(items, [("def \x96", "ghi \x97")])
self.assert_(isinstance(items[0][0], str))
self.assert_(isinstance(items[0][1], str))
else:
self.assertEquals(s, "abc \xc2\x95")
self.assertEquals(items, [("def \xc2\x96", "ghi \xc2\x97")])
def test_main():
test_support.run_unittest(XMLRPCTestCase)