Commit f3a5c35a authored by Walter Dörwald's avatar Walter Dörwald

Remove have_unicode checks and merge those tests into the

normal code (or drop them if they only repeat previous
tests).
parent c314596c
......@@ -752,35 +752,34 @@ class CharacterTest(StringTest):
tests.append(CharacterTest)
if test_support.have_unicode:
class UnicodeTest(StringTest):
typecode = 'u'
example = '\x01\u263a\x00\ufeff'
smallerexample = '\x01\u263a\x00\ufefe'
biggerexample = '\x01\u263a\x01\ufeff'
outside = str('\x33')
minitemsize = 2
def test_unicode(self):
self.assertRaises(TypeError, array.array, 'b', 'foo')
a = array.array('u', '\xa0\xc2\u1234')
a.fromunicode(' ')
a.fromunicode('')
a.fromunicode('')
a.fromunicode('\x11abc\xff\u1234')
s = a.tounicode()
self.assertEqual(s, '\xa0\xc2\u1234 \x11abc\xff\u1234')
s = '\x00="\'a\\b\x80\xff\u0000\u0001\u1234'
a = array.array('u', s)
self.assertEqual(
repr(a),
"array('u', '\\x00=\"\\'a\\\\b\\x80\\xff\\x00\\x01\\u1234')")
self.assertRaises(TypeError, a.fromunicode)
tests.append(UnicodeTest)
class UnicodeTest(StringTest):
typecode = 'u'
example = '\x01\u263a\x00\ufeff'
smallerexample = '\x01\u263a\x00\ufefe'
biggerexample = '\x01\u263a\x01\ufeff'
outside = str('\x33')
minitemsize = 2
def test_unicode(self):
self.assertRaises(TypeError, array.array, 'b', 'foo')
a = array.array('u', '\xa0\xc2\u1234')
a.fromunicode(' ')
a.fromunicode('')
a.fromunicode('')
a.fromunicode('\x11abc\xff\u1234')
s = a.tounicode()
self.assertEqual(s, '\xa0\xc2\u1234 \x11abc\xff\u1234')
s = '\x00="\'a\\b\x80\xff\u0000\u0001\u1234'
a = array.array('u', s)
self.assertEqual(
repr(a),
"array('u', '\\x00=\"\\'a\\\\b\\x80\\xff\\x00\\x01\\u1234')")
self.assertRaises(TypeError, a.fromunicode)
tests.append(UnicodeTest)
class NumberTest(BaseTest):
......
This diff is collapsed.
......@@ -226,8 +226,6 @@ class ComplexTest(unittest.TestCase):
self.assertRaises(TypeError, complex, 1, "1")
self.assertEqual(complex(" 3.14+J "), 3.14+1j)
if test_support.have_unicode:
self.assertEqual(complex(str(" 3.14+J ")), 3.14+1j)
# SF bug 543840: complex(string) accepts strings with \0
# Fixed in 2.3.
......@@ -250,9 +248,8 @@ class ComplexTest(unittest.TestCase):
self.assertRaises(ValueError, complex, "1+2j)")
self.assertRaises(ValueError, complex, "1+(2j)")
self.assertRaises(ValueError, complex, "(1+2j)123")
if test_support.have_unicode:
self.assertRaises(ValueError, complex, str("1"*500))
self.assertRaises(ValueError, complex, str("x"))
self.assertRaises(ValueError, complex, "1"*500)
self.assertRaises(ValueError, complex, "x")
class EvilExc(Exception):
pass
......
from test.test_support import TestFailed, have_unicode
from test.test_support import TestFailed
class base_set:
......@@ -55,36 +55,6 @@ except TypeError:
pass
if have_unicode:
# Test char in Unicode
check('c' in str('abc'), "'c' not in u'abc'")
check('d' not in str('abc'), "'d' in u'abc'")
check('' in str(''), "'' not in u''")
check(str('') in '', "u'' not in ''")
check(str('') in str(''), "u'' not in u''")
check('' in str('abc'), "'' not in u'abc'")
check(str('') in 'abc', "u'' not in 'abc'")
check(str('') in str('abc'), "u'' not in u'abc'")
try:
None in str('abc')
check(0, "None in u'abc' did not raise error")
except TypeError:
pass
# Test Unicode char in Unicode
check(str('c') in str('abc'), "u'c' not in u'abc'")
check(str('d') not in str('abc'), "u'd' in u'abc'")
# Test Unicode char in string
check(str('c') in 'abc', "u'c' not in 'abc'")
check(str('d') not in 'abc', "u'd' in 'abc'")
# A collection of tests on builtin sequence types
a = list(range(10))
for i in a:
......
......@@ -242,8 +242,7 @@ class TestIsInstanceIsSubclass(unittest.TestCase):
self.assertEqual(True, issubclass(NewSuper, (NewChild, (NewSuper,))))
self.assertEqual(True, issubclass(int, (int, (float, int))))
if test_support.have_unicode:
self.assertEqual(True, issubclass(str, (str, (Child, NewChild, basestring))))
self.assertEqual(True, issubclass(str, (str, (Child, NewChild, basestring))))
def test_subclass_recursion_limit(self):
# make sure that issubclass raises RuntimeError before the C stack is
......
# Test iterators.
import unittest
from test.test_support import run_unittest, TESTFN, unlink, have_unicode
from test.test_support import run_unittest, TESTFN, unlink
# Test result of triple loop (too big to inline)
TRIPLETS = [(0, 0, 0), (0, 0, 1), (0, 0, 2),
......@@ -213,13 +213,6 @@ class TestCase(unittest.TestCase):
def test_iter_string(self):
self.check_for_loop(iter("abcde"), ["a", "b", "c", "d", "e"])
# Test a Unicode string
if have_unicode:
def test_iter_unicode(self):
self.check_for_loop(iter(str("abcde")),
[str("a"), str("b"), str("c"),
str("d"), str("e")])
# Test a directory
def test_iter_dict(self):
dict = {}
......@@ -500,7 +493,6 @@ class TestCase(unittest.TestCase):
for y in NoGuessLen5(), Guess3Len5(), Guess30Len5():
self.assertEqual(lzip(x, y), expected)
# This test case will be removed if we don't have Unicode
def test_unicode_join_endcase(self):
# This class inserts a Unicode object into its argument's natural
......@@ -517,7 +509,7 @@ class TestCase(unittest.TestCase):
i = self.i
self.i = i+1
if i == 2:
return str("fooled you!")
return "fooled you!"
return next(self.it)
f = open(TESTFN, "w")
......@@ -541,8 +533,6 @@ class TestCase(unittest.TestCase):
unlink(TESTFN)
except OSError:
pass
if not have_unicode:
def test_unicode_join_endcase(self): pass
# Test iterators with 'x in y' and 'x not in y'.
def test_in_and_not_in(self):
......
"""Test compiler changes for unary ops (+, -, ~) introduced in Python 2.2"""
import unittest
from test.test_support import run_unittest, have_unicode
from test.test_support import run_unittest
class UnaryOpTestCase(unittest.TestCase):
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment