summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>2007-06-18 18:44:28 (GMT)
committerGuido van Rossum <guido@python.org>2007-06-18 18:44:28 (GMT)
commit31f72d72b1e0c772becbfa9bbd3ab1827c704726 (patch)
tree6dad5b0ed7c154497f74a0cee305fc4ec32e2e65 /Lib
parentc43e79f3c87ebf19fec2e481068bf48262096716 (diff)
downloadcpython-31f72d72b1e0c772becbfa9bbd3ab1827c704726.zip
cpython-31f72d72b1e0c772becbfa9bbd3ab1827c704726.tar.gz
cpython-31f72d72b1e0c772becbfa9bbd3ab1827c704726.tar.bz2
"Fix" the array module test -- by ripping out the 'c' typecode.
(We already have 'b' for bytes and 'u' for unicode.)
Diffstat (limited to 'Lib')
-rwxr-xr-xLib/test/test_array.py42
1 files changed, 2 insertions, 40 deletions
diff --git a/Lib/test/test_array.py b/Lib/test/test_array.py
index 0d4c219..9b11edf 100755
--- a/Lib/test/test_array.py
+++ b/Lib/test/test_array.py
@@ -17,7 +17,7 @@ class ArraySubclassWithKwargs(array.array):
array.array.__init__(typecode)
tests = [] # list to accumulate all tests
-typecodes = "cubBhHiIlLfd"
+typecodes = "ubBhHiIlLfd"
class BadConstructorTest(unittest.TestCase):
@@ -676,7 +676,7 @@ class BaseTest(unittest.TestCase):
def test_buffer(self):
a = array.array(self.typecode, self.example)
- b = buffer(a)
+ b = bytes(buffer(a))
self.assertEqual(b[0], a.tostring()[0])
def test_weakref(self):
@@ -708,44 +708,6 @@ class StringTest(BaseTest):
a = array.array(self.typecode, self.example)
self.assertRaises(TypeError, a.__setitem__, 0, self.example[:2])
-class CharacterTest(StringTest):
- typecode = 'c'
- example = '\x01azAZ\x00\xfe'
- smallerexample = '\x01azAY\x00\xfe'
- biggerexample = '\x01azAZ\x00\xff'
- outside = '\x33'
- minitemsize = 1
-
- def test_subbclassing(self):
- class EditableString(array.array):
- def __new__(cls, s, *args, **kwargs):
- return array.array.__new__(cls, 'c', s)
-
- def __init__(self, s, color='blue'):
- self.color = color
-
- def strip(self):
- self[:] = array.array('c', self.tostring().strip())
-
- def __repr__(self):
- return 'EditableString(%r)' % self.tostring()
-
- s = EditableString("\ttest\r\n")
- s.strip()
- self.assertEqual(s.tostring(), "test")
-
- self.assertEqual(s.color, "blue")
- s.color = "red"
- self.assertEqual(s.color, "red")
- self.assertEqual(list(s.__dict__.keys()), ["color"])
-
- def test_nounicode(self):
- a = array.array(self.typecode, self.example)
- self.assertRaises(ValueError, a.fromunicode, str(''))
- self.assertRaises(ValueError, a.tounicode)
-
-tests.append(CharacterTest)
-
class UnicodeTest(StringTest):
typecode = 'u'
example = '\x01\u263a\x00\ufeff'