[Python-checkins] python/dist/src/Lib/test test_generators.py,1.36,1.37

fdrake@users.sourceforge.net fdrake@users.sourceforge.net
Fri, 09 Aug 2002 11:37:12 -0700


Update of /cvsroot/python/python/dist/src/Lib/test
In directory usw-pr-cvs1:/tmp/cvs-serv19070

Modified Files:
	test_generators.py 
Log Message:
Add tests for weakref support for generator-iterators.
Part of fixing SF bug #591704.


Index: test_generators.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_generators.py,v
retrieving revision 1.36
retrieving revision 1.37
diff -C2 -d -r1.36 -r1.37
*** test_generators.py	23 Jul 2002 19:03:54 -0000	1.36
--- test_generators.py	9 Aug 2002 18:37:10 -0000	1.37
***************
*** 1360,1363 ****
--- 1360,1387 ----
  """
  
+ weakref_tests = """\
+ Generators are weakly referencable:
+ 
+ >>> import weakref
+ >>> def gen():
+ ...     yield 'foo!'
+ ...
+ >>> wr = weakref.ref(gen)
+ >>> wr() is gen
+ True
+ >>> p = weakref.proxy(gen)
+ 
+ Generator-iterators are weakly referencable as well:
+ 
+ >>> gi = gen()
+ >>> wr = weakref.ref(gi)
+ >>> wr() is gi
+ True
+ >>> p = weakref.proxy(gi)
+ >>> list(p)
+ ['foo!']
+ 
+ """
+ 
  __test__ = {"tut":      tutorial_tests,
              "pep":      pep_tests,
***************
*** 1365,1369 ****
              "fun":      fun_tests,
              "syntax":   syntax_tests,
!             "conjoin":  conjoin_tests}
  
  # Magic test name that regrtest.py invokes *after* importing this module.
--- 1389,1395 ----
              "fun":      fun_tests,
              "syntax":   syntax_tests,
!             "conjoin":  conjoin_tests,
!             "weakref":  weakref_tests,
!             }
  
  # Magic test name that regrtest.py invokes *after* importing this module.