summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_array.py
diff options
context:
space:
mode:
authorRaymond Hettinger <python@rcn.com>2004-05-31 00:35:52 (GMT)
committerRaymond Hettinger <python@rcn.com>2004-05-31 00:35:52 (GMT)
commitcb87bc8e7ee3a2ffd83dd1b12fcfa1c01aa740aa (patch)
treef9e95a569fd2b935cccbdd0a2ba2ea88d8348276 /Lib/test/test_array.py
parent691d80532b0a0204e92de35ecba1472d87af6e94 (diff)
downloadcpython-cb87bc8e7ee3a2ffd83dd1b12fcfa1c01aa740aa.zip
cpython-cb87bc8e7ee3a2ffd83dd1b12fcfa1c01aa740aa.tar.gz
cpython-cb87bc8e7ee3a2ffd83dd1b12fcfa1c01aa740aa.tar.bz2
Add weakref support to array.array and file objects.
Diffstat (limited to 'Lib/test/test_array.py')
-rwxr-xr-xLib/test/test_array.py10
1 files changed, 10 insertions, 0 deletions
diff --git a/Lib/test/test_array.py b/Lib/test/test_array.py
index 0f3e07f..d03618d 100755
--- a/Lib/test/test_array.py
+++ b/Lib/test/test_array.py
@@ -5,6 +5,7 @@
import unittest
from test import test_support
+from weakref import proxy
import array, cStringIO, math
tests = [] # list to accumulate all tests
@@ -614,6 +615,13 @@ class BaseTest(unittest.TestCase):
b = buffer(a)
self.assertEqual(b[0], a.tostring()[0])
+ def test_weakref(self):
+ s = array.array(self.typecode, self.example)
+ p = proxy(s)
+ self.assertEqual(p.tostring(), s.tostring())
+ s = None
+ self.assertRaises(ReferenceError, len, p)
+
def test_bug_782369(self):
import sys
if hasattr(sys, "getrefcount"):
@@ -624,6 +632,8 @@ class BaseTest(unittest.TestCase):
b = array.array('B', range(64))
self.assertEqual(rc, sys.getrefcount(10))
+
+
class StringTest(BaseTest):
def test_setitem(self):