[pypy-svn] rev 2676 - pypy/trunk/src/pypy/interpreter/test
alex at codespeak.net
alex at codespeak.net
Mon Dec 22 16:50:27 CET 2003
Author: alex
Date: Mon Dec 22 16:50:26 2003
New Revision: 2676
Modified:
pypy/trunk/src/pypy/interpreter/test/test_generator.py
Log:
added unit-test to show a bug in generators when a StopIteration
propagates from something the generator call (typically a .next() call).
Modified: pypy/trunk/src/pypy/interpreter/test/test_generator.py
==============================================================================
--- pypy/trunk/src/pypy/interpreter/test/test_generator.py (original)
+++ pypy/trunk/src/pypy/interpreter/test/test_generator.py Mon Dec 22 16:50:26 2003
@@ -8,13 +8,13 @@
def f():
yield 1
self.assertEquals(f().next(), 1)
-
+
def test_generator2(self):
def f():
yield 1
g = f()
self.assertEquals(g.next(), 1)
- self.assertRaises(StopIteration, g.next)
+ self.assertRaises(StopIteration, g.next)
def test_generator3(self):
def f():
@@ -34,7 +34,14 @@
raise StopIteration
g = f()
self.assertEquals([x for x in g], [1])
-
+
+ def test_generator_propagate_stopiteration(self):
+ def f():
+ it = iter([1])
+ while 1: yield it.next()
+ g = f()
+ self.assertEquals([x for x in g], [1])
+
def test_generator_restart(self):
def g():
i = me.next()
More information about the Pypy-commit
mailing list