Disable a few other tests, that can't work if Python is compiled without

Unicode support.
This commit is contained in:
Walter Dörwald 2005-08-03 17:09:04 +00:00
parent 649f8e7de2
commit 4e41a4b64c
4 changed files with 30 additions and 18 deletions

View File

@ -582,6 +582,7 @@ class BuiltinTest(unittest.TestCase):
self.assertRaises(TypeError, getattr, sys, 1)
self.assertRaises(TypeError, getattr, sys, 1, "foo")
self.assertRaises(TypeError, getattr)
if have_unicode:
self.assertRaises(UnicodeError, getattr, sys, unichr(sys.maxunicode))
def test_hasattr(self):
@ -589,6 +590,7 @@ class BuiltinTest(unittest.TestCase):
self.assert_(hasattr(sys, 'stdout'))
self.assertRaises(TypeError, hasattr, sys, 1)
self.assertRaises(TypeError, hasattr)
if have_unicode:
self.assertRaises(UnicodeError, hasattr, sys, unichr(sys.maxunicode))
def test_hash(self):
@ -1101,6 +1103,7 @@ class BuiltinTest(unittest.TestCase):
if have_unicode:
self.assertEqual(ord(unichr(sys.maxunicode)), sys.maxunicode)
self.assertRaises(TypeError, ord, 42)
if have_unicode:
self.assertRaises(TypeError, ord, unicode("12"))
def test_pow(self):
@ -1494,11 +1497,17 @@ class TestSorted(unittest.TestCase):
def test_inputtypes(self):
s = 'abracadabra'
for T in [unicode, list, tuple]:
types = [list, tuple]
if have_unicode:
types.insert(0, unicode)
for T in types:
self.assertEqual(sorted(s), sorted(T(s)))
s = ''.join(dict.fromkeys(s).keys()) # unique letters only
for T in [unicode, set, frozenset, list, tuple, dict.fromkeys]:
types = [set, frozenset, list, tuple, dict.fromkeys]
if have_unicode:
types.insert(0, unicode)
for T in types:
self.assertEqual(sorted(s), sorted(T(s)))
def test_baddecorator(self):

View File

@ -243,6 +243,7 @@ class TestIsInstanceIsSubclass(unittest.TestCase):
self.assertEqual(True, issubclass(NewSuper, (NewChild, (NewSuper,))))
self.assertEqual(True, issubclass(int, (long, (float, int))))
if test_support.have_unicode:
self.assertEqual(True, issubclass(str, (unicode, (Child, NewChild, basestring))))
def test_subclass_recursion_limit(self):

View File

@ -247,6 +247,7 @@ class SysModuleTest(unittest.TestCase):
self.assert_(isinstance(sys.executable, basestring))
self.assert_(isinstance(sys.hexversion, int))
self.assert_(isinstance(sys.maxint, int))
if test.test_support.have_unicode:
self.assert_(isinstance(sys.maxunicode, int))
self.assert_(isinstance(sys.platform, basestring))
self.assert_(isinstance(sys.prefix, basestring))

View File

@ -328,6 +328,7 @@ What a mess!
self.check_wrap(text, 30,
[" This is a sentence with", "leading whitespace."])
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