summaryrefslogtreecommitdiffstats
path: root/Lib/test
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>2007-10-19 22:06:24 (GMT)
committerGuido van Rossum <guido@python.org>2007-10-19 22:06:24 (GMT)
commit75a902db7859a4751743e98530c5d96a672641be (patch)
treea730c966dcfc993a800078004aae3a6094a75a6a /Lib/test
parent21431e85d505b9698c085c25cbf1b2997a352b85 (diff)
downloadcpython-75a902db7859a4751743e98530c5d96a672641be.zip
cpython-75a902db7859a4751743e98530c5d96a672641be.tar.gz
cpython-75a902db7859a4751743e98530c5d96a672641be.tar.bz2
Patch 1280, by Alexandre Vassalotti.
Make PyString's indexing and iteration return integers. (I changed a few of Alexandre's decisions -- GvR.)
Diffstat (limited to 'Lib/test')
-rw-r--r--Lib/test/string_tests.py4
-rw-r--r--Lib/test/test_bytes.py2
-rw-r--r--Lib/test/test_set.py16
-rw-r--r--Lib/test/test_struct.py4
4 files changed, 15 insertions, 11 deletions
diff --git a/Lib/test/string_tests.py b/Lib/test/string_tests.py
index cb8900d..9da062e 100644
--- a/Lib/test/string_tests.py
+++ b/Lib/test/string_tests.py
@@ -558,6 +558,10 @@ class CommonTest(BaseTest):
a = self.type2test('DNSSEC')
b = self.type2test('')
for c in a:
+ # Special case for the str8, since indexing returns a integer
+ # XXX Maybe it would be a good idea to seperate str8's tests...
+ if self.type2test == str8:
+ c = chr(c)
b += c
hash(b)
self.assertEqual(hash(a), hash(b))
diff --git a/Lib/test/test_bytes.py b/Lib/test/test_bytes.py
index 391a660..c7c6bd3 100644
--- a/Lib/test/test_bytes.py
+++ b/Lib/test/test_bytes.py
@@ -348,7 +348,7 @@ class BytesTest(unittest.TestCase):
sample = str8("Hello world\n\x80\x81\xfe\xff")
buf = memoryview(sample)
b = bytes(buf)
- self.assertEqual(b, bytes(map(ord, sample)))
+ self.assertEqual(b, bytes(sample))
def test_to_str(self):
sample = "Hello world\n\x80\x81\xfe\xff"
diff --git a/Lib/test/test_set.py b/Lib/test/test_set.py
index 3b8e747..86a5636 100644
--- a/Lib/test/test_set.py
+++ b/Lib/test/test_set.py
@@ -72,7 +72,7 @@ class TestJointOps(unittest.TestCase):
self.assertEqual(type(u), self.thetype)
self.assertRaises(PassThru, self.s.union, check_pass_thru())
self.assertRaises(TypeError, self.s.union, [[]])
- for C in set, frozenset, dict.fromkeys, str, str8, list, tuple:
+ for C in set, frozenset, dict.fromkeys, str, list, tuple:
self.assertEqual(self.thetype('abcba').union(C('cdc')), set('abcd'))
self.assertEqual(self.thetype('abcba').union(C('efgfe')), set('abcefg'))
self.assertEqual(self.thetype('abcba').union(C('ccb')), set('abc'))
@@ -96,7 +96,7 @@ class TestJointOps(unittest.TestCase):
self.assertEqual(self.s, self.thetype(self.word))
self.assertEqual(type(i), self.thetype)
self.assertRaises(PassThru, self.s.intersection, check_pass_thru())
- for C in set, frozenset, dict.fromkeys, str, str8, list, tuple:
+ for C in set, frozenset, dict.fromkeys, str, list, tuple:
self.assertEqual(self.thetype('abcba').intersection(C('cdc')), set('cc'))
self.assertEqual(self.thetype('abcba').intersection(C('efgfe')), set(''))
self.assertEqual(self.thetype('abcba').intersection(C('ccb')), set('bc'))
@@ -121,7 +121,7 @@ class TestJointOps(unittest.TestCase):
self.assertEqual(type(i), self.thetype)
self.assertRaises(PassThru, self.s.difference, check_pass_thru())
self.assertRaises(TypeError, self.s.difference, [[]])
- for C in set, frozenset, dict.fromkeys, str, str8, list, tuple:
+ for C in set, frozenset, dict.fromkeys, str, list, tuple:
self.assertEqual(self.thetype('abcba').difference(C('cdc')), set('ab'))
self.assertEqual(self.thetype('abcba').difference(C('efgfe')), set('abc'))
self.assertEqual(self.thetype('abcba').difference(C('ccb')), set('a'))
@@ -146,7 +146,7 @@ class TestJointOps(unittest.TestCase):
self.assertEqual(type(i), self.thetype)
self.assertRaises(PassThru, self.s.symmetric_difference, check_pass_thru())
self.assertRaises(TypeError, self.s.symmetric_difference, [[]])
- for C in set, frozenset, dict.fromkeys, str, str8, list, tuple:
+ for C in set, frozenset, dict.fromkeys, str, list, tuple:
self.assertEqual(self.thetype('abcba').symmetric_difference(C('cdc')), set('abd'))
self.assertEqual(self.thetype('abcba').symmetric_difference(C('efgfe')), set('abcefg'))
self.assertEqual(self.thetype('abcba').symmetric_difference(C('ccb')), set('a'))
@@ -390,7 +390,7 @@ class TestSet(TestJointOps):
self.assertRaises(PassThru, self.s.update, check_pass_thru())
self.assertRaises(TypeError, self.s.update, [[]])
for p, q in (('cdc', 'abcd'), ('efgfe', 'abcefg'), ('ccb', 'abc'), ('ef', 'abcef')):
- for C in set, frozenset, dict.fromkeys, str, str8, list, tuple:
+ for C in set, frozenset, dict.fromkeys, str, list, tuple:
s = self.thetype('abcba')
self.assertEqual(s.update(C(p)), None)
self.assertEqual(s, set(q))
@@ -411,7 +411,7 @@ class TestSet(TestJointOps):
self.assertRaises(PassThru, self.s.intersection_update, check_pass_thru())
self.assertRaises(TypeError, self.s.intersection_update, [[]])
for p, q in (('cdc', 'c'), ('efgfe', ''), ('ccb', 'bc'), ('ef', '')):
- for C in set, frozenset, dict.fromkeys, str, str8, list, tuple:
+ for C in set, frozenset, dict.fromkeys, str, list, tuple:
s = self.thetype('abcba')
self.assertEqual(s.intersection_update(C(p)), None)
self.assertEqual(s, set(q))
@@ -436,7 +436,7 @@ class TestSet(TestJointOps):
self.assertRaises(TypeError, self.s.difference_update, [[]])
self.assertRaises(TypeError, self.s.symmetric_difference_update, [[]])
for p, q in (('cdc', 'ab'), ('efgfe', 'abc'), ('ccb', 'a'), ('ef', 'abc')):
- for C in set, frozenset, dict.fromkeys, str, str8, list, tuple:
+ for C in set, frozenset, dict.fromkeys, str, list, tuple:
s = self.thetype('abcba')
self.assertEqual(s.difference_update(C(p)), None)
self.assertEqual(s, set(q))
@@ -460,7 +460,7 @@ class TestSet(TestJointOps):
self.assertRaises(PassThru, self.s.symmetric_difference_update, check_pass_thru())
self.assertRaises(TypeError, self.s.symmetric_difference_update, [[]])
for p, q in (('cdc', 'abd'), ('efgfe', 'abcefg'), ('ccb', 'a'), ('ef', 'abcef')):
- for C in set, frozenset, dict.fromkeys, str, str8, list, tuple:
+ for C in set, frozenset, dict.fromkeys, str, list, tuple:
s = self.thetype('abcba')
self.assertEqual(s.symmetric_difference_update(C(p)), None)
self.assertEqual(s, set(q))
diff --git a/Lib/test/test_struct.py b/Lib/test/test_struct.py
index 83d7efb..cc6db32 100644
--- a/Lib/test/test_struct.py
+++ b/Lib/test/test_struct.py
@@ -674,8 +674,8 @@ def test_bool():
elif not prefix and verbose:
print('size of bool in native format is %i' % (len(packed)))
- for c in str8('\x01\x7f\xff\x0f\xf0'):
- if struct.unpack('>t', c)[0] is not True:
+ for c in b'\x01\x7f\xff\x0f\xf0':
+ if struct.unpack('>t', bytes([c]))[0] is not True:
raise TestFailed('%c did not unpack as True' % c)
test_bool()