[Python-checkins] python/dist/src/Lib/test test_re.py, 1.49, 1.50 test_socket.py, 1.68, 1.69

rhettinger at users.sourceforge.net rhettinger at users.sourceforge.net
Sun May 30 23:09:29 EDT 2004


Update of /cvsroot/python/python/dist/src/Lib/test
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv432/Lib/test

Modified Files:
	test_re.py test_socket.py 
Log Message:
Add weakref support to sockets and re pattern objects.



Index: test_re.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_re.py,v
retrieving revision 1.49
retrieving revision 1.50
diff -C2 -d -r1.49 -r1.50
*** test_re.py	7 May 2004 07:18:12 -0000	1.49
--- test_re.py	31 May 2004 03:09:25 -0000	1.50
***************
*** 6,9 ****
--- 6,10 ----
  from sre import Scanner
  import sys, os, traceback
+ from weakref import proxy
  
  # Misc tests from Tim Peters' re.doc
***************
*** 16,19 ****
--- 17,27 ----
  
  class ReTests(unittest.TestCase):
+ 
+     def test_weakref(self):
+         s = 'QabbbcR'
+         x = re.compile('ab+c')
+         y = proxy(x)
+         self.assertEqual(x.findall('QabbbcR'), y.findall('QabbbcR'))
+ 
      def test_search_star_plus(self):
          self.assertEqual(re.search('x*', 'axx').span(0), (0, 0))

Index: test_socket.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_socket.py,v
retrieving revision 1.68
retrieving revision 1.69
diff -C2 -d -r1.68 -r1.69
*** test_socket.py	28 Mar 2004 02:20:45 -0000	1.68
--- test_socket.py	31 May 2004 03:09:25 -0000	1.69
***************
*** 10,13 ****
--- 10,14 ----
  import Queue
  import sys
+ from weakref import proxy
  
  PORT = 50007
***************
*** 192,195 ****
--- 193,209 ----
  class GeneralModuleTests(unittest.TestCase):
  
+     def test_weakref(self):
+         s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
+         p = proxy(s)
+         self.assertEqual(p.fileno(), s.fileno())
+         s.close()
+         s = None
+         try:
+             p.fileno()
+         except ReferenceError:
+             pass
+         else:
+             self.fail('Socket proxy still exists')
+ 
      def testSocketError(self):
          # Testing socket module exceptions




More information about the Python-checkins mailing list