[Python-checkins] python/dist/src/Lib/test test_array.py, 1.28,
1.29 test_file.py, 1.14, 1.15
rhettinger at users.sourceforge.net
rhettinger at users.sourceforge.net
Sun May 30 20:35:55 EDT 2004
Update of /cvsroot/python/python/dist/src/Lib/test
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10541/Lib/test
Modified Files:
test_array.py test_file.py
Log Message:
Add weakref support to array.array and file objects.
Index: test_array.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_array.py,v
retrieving revision 1.28
retrieving revision 1.29
diff -C2 -d -r1.28 -r1.29
*** test_array.py 14 Mar 2004 05:43:58 -0000 1.28
--- test_array.py 31 May 2004 00:35:52 -0000 1.29
***************
*** 6,9 ****
--- 6,10 ----
import unittest
from test import test_support
+ from weakref import proxy
import array, cStringIO, math
***************
*** 615,618 ****
--- 616,626 ----
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
***************
*** 625,628 ****
--- 633,638 ----
self.assertEqual(rc, sys.getrefcount(10))
+
+
class StringTest(BaseTest):
Index: test_file.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_file.py,v
retrieving revision 1.14
retrieving revision 1.15
diff -C2 -d -r1.14 -r1.15
*** test_file.py 4 Apr 2004 07:00:07 -0000 1.14
--- test_file.py 31 May 2004 00:35:52 -0000 1.15
***************
*** 2,9 ****
--- 2,24 ----
import os
from array import array
+ from weakref import proxy
from test.test_support import verify, TESTFN, TestFailed
from UserList import UserList
+ # verify weak references
+ f = file(TESTFN, 'w')
+ p = proxy(f)
+ p.write('teststring')
+ verify(f.tell(), p.tell())
+ f.close()
+ f = None
+ try:
+ p.tell()
+ except ReferenceError:
+ pass
+ else:
+ raise TestFailed('file proxy still exists when the file is gone')
+
# verify expected attributes exist
f = file(TESTFN, 'w')
More information about the Python-checkins
mailing list