Kaydet (Commit) 1f5947b3 authored tarafından 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).
üst 02427050
...@@ -752,35 +752,34 @@ class CharacterTest(StringTest): ...@@ -752,35 +752,34 @@ class CharacterTest(StringTest):
tests.append(CharacterTest) tests.append(CharacterTest)
if test_support.have_unicode: class UnicodeTest(StringTest):
class UnicodeTest(StringTest): typecode = 'u'
typecode = 'u' example = '\x01\u263a\x00\ufeff'
example = '\x01\u263a\x00\ufeff' smallerexample = '\x01\u263a\x00\ufefe'
smallerexample = '\x01\u263a\x00\ufefe' biggerexample = '\x01\u263a\x01\ufeff'
biggerexample = '\x01\u263a\x01\ufeff' outside = str('\x33')
outside = str('\x33') minitemsize = 2
minitemsize = 2
def test_unicode(self):
def test_unicode(self): self.assertRaises(TypeError, array.array, 'b', 'foo')
self.assertRaises(TypeError, array.array, 'b', 'foo')
a = array.array('u', '\xa0\xc2\u1234')
a = array.array('u', '\xa0\xc2\u1234') a.fromunicode(' ')
a.fromunicode(' ') a.fromunicode('')
a.fromunicode('') a.fromunicode('')
a.fromunicode('') a.fromunicode('\x11abc\xff\u1234')
a.fromunicode('\x11abc\xff\u1234') s = a.tounicode()
s = a.tounicode() self.assertEqual(s, '\xa0\xc2\u1234 \x11abc\xff\u1234')
self.assertEqual(s, '\xa0\xc2\u1234 \x11abc\xff\u1234')
s = '\x00="\'a\\b\x80\xff\u0000\u0001\u1234'
s = '\x00="\'a\\b\x80\xff\u0000\u0001\u1234' a = array.array('u', s)
a = array.array('u', s) self.assertEqual(
self.assertEqual( repr(a),
repr(a), "array('u', '\\x00=\"\\'a\\\\b\\x80\\xff\\x00\\x01\\u1234')")
"array('u', '\\x00=\"\\'a\\\\b\\x80\\xff\\x00\\x01\\u1234')")
self.assertRaises(TypeError, a.fromunicode)
self.assertRaises(TypeError, a.fromunicode)
tests.append(UnicodeTest)
tests.append(UnicodeTest)
class NumberTest(BaseTest): class NumberTest(BaseTest):
......
This diff is collapsed.
...@@ -226,8 +226,6 @@ class ComplexTest(unittest.TestCase): ...@@ -226,8 +226,6 @@ class ComplexTest(unittest.TestCase):
self.assertRaises(TypeError, complex, 1, "1") self.assertRaises(TypeError, complex, 1, "1")
self.assertEqual(complex(" 3.14+J "), 3.14+1j) 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 # SF bug 543840: complex(string) accepts strings with \0
# Fixed in 2.3. # Fixed in 2.3.
...@@ -250,9 +248,8 @@ class ComplexTest(unittest.TestCase): ...@@ -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)") self.assertRaises(ValueError, complex, "1+(2j)")
self.assertRaises(ValueError, complex, "(1+2j)123") self.assertRaises(ValueError, complex, "(1+2j)123")
if test_support.have_unicode: self.assertRaises(ValueError, complex, "1"*500)
self.assertRaises(ValueError, complex, str("1"*500)) self.assertRaises(ValueError, complex, "x")
self.assertRaises(ValueError, complex, str("x"))
class EvilExc(Exception): class EvilExc(Exception):
pass pass
......
from test.test_support import TestFailed, have_unicode from test.test_support import TestFailed
class base_set: class base_set:
...@@ -55,36 +55,6 @@ except TypeError: ...@@ -55,36 +55,6 @@ except TypeError:
pass 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 collection of tests on builtin sequence types
a = list(range(10)) a = list(range(10))
for i in a: for i in a:
......
...@@ -242,8 +242,7 @@ class TestIsInstanceIsSubclass(unittest.TestCase): ...@@ -242,8 +242,7 @@ class TestIsInstanceIsSubclass(unittest.TestCase):
self.assertEqual(True, issubclass(NewSuper, (NewChild, (NewSuper,)))) self.assertEqual(True, issubclass(NewSuper, (NewChild, (NewSuper,))))
self.assertEqual(True, issubclass(int, (int, (float, int)))) 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): def test_subclass_recursion_limit(self):
# make sure that issubclass raises RuntimeError before the C stack is # make sure that issubclass raises RuntimeError before the C stack is
......
# Test iterators. # Test iterators.
import unittest 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) # Test result of triple loop (too big to inline)
TRIPLETS = [(0, 0, 0), (0, 0, 1), (0, 0, 2), TRIPLETS = [(0, 0, 0), (0, 0, 1), (0, 0, 2),
...@@ -213,13 +213,6 @@ class TestCase(unittest.TestCase): ...@@ -213,13 +213,6 @@ class TestCase(unittest.TestCase):
def test_iter_string(self): def test_iter_string(self):
self.check_for_loop(iter("abcde"), ["a", "b", "c", "d", "e"]) 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 # Test a directory
def test_iter_dict(self): def test_iter_dict(self):
dict = {} dict = {}
...@@ -500,7 +493,6 @@ class TestCase(unittest.TestCase): ...@@ -500,7 +493,6 @@ class TestCase(unittest.TestCase):
for y in NoGuessLen5(), Guess3Len5(), Guess30Len5(): for y in NoGuessLen5(), Guess3Len5(), Guess30Len5():
self.assertEqual(lzip(x, y), expected) self.assertEqual(lzip(x, y), expected)
# This test case will be removed if we don't have Unicode
def test_unicode_join_endcase(self): def test_unicode_join_endcase(self):
# This class inserts a Unicode object into its argument's natural # This class inserts a Unicode object into its argument's natural
...@@ -517,7 +509,7 @@ class TestCase(unittest.TestCase): ...@@ -517,7 +509,7 @@ class TestCase(unittest.TestCase):
i = self.i i = self.i
self.i = i+1 self.i = i+1
if i == 2: if i == 2:
return str("fooled you!") return "fooled you!"
return next(self.it) return next(self.it)
f = open(TESTFN, "w") f = open(TESTFN, "w")
...@@ -541,8 +533,6 @@ class TestCase(unittest.TestCase): ...@@ -541,8 +533,6 @@ class TestCase(unittest.TestCase):
unlink(TESTFN) unlink(TESTFN)
except OSError: except OSError:
pass pass
if not have_unicode:
def test_unicode_join_endcase(self): pass
# Test iterators with 'x in y' and 'x not in y'. # Test iterators with 'x in y' and 'x not in y'.
def test_in_and_not_in(self): def test_in_and_not_in(self):
......
"""Test compiler changes for unary ops (+, -, ~) introduced in Python 2.2""" """Test compiler changes for unary ops (+, -, ~) introduced in Python 2.2"""
import unittest import unittest
from test.test_support import run_unittest, have_unicode from test.test_support import run_unittest
class UnaryOpTestCase(unittest.TestCase): 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