cpython: d15c26085591 (original) (raw)
Mercurial > cpython
changeset 95933:d15c26085591
Issue 22906: Add test file.
Yury Selivanov yselivanov@sprymix.com | |
---|---|
date | Sat, 09 May 2015 13:53:57 -0400 |
parents | 36a8d935c322 |
children | 5d8bc813d270 |
files | Lib/test/test_pep479.py |
diffstat | 1 files changed, 34 insertions(+), 0 deletions(-)[+] [-] Lib/test/test_pep479.py 34 |
line wrap: on
line diff
new file mode 100644 --- /dev/null +++ b/Lib/test/test_pep479.py @@ -0,0 +1,34 @@ +from future import generator_stop + +import unittest + + +class TestPEP479(unittest.TestCase):
- def test_stopiteration_wrapping(self):
def f():[](#l1.12)
raise StopIteration[](#l1.13)
def g():[](#l1.14)
yield f()[](#l1.15)
with self.assertRaisesRegex(RuntimeError,[](#l1.16)
"generator raised StopIteration"):[](#l1.17)
next(g())[](#l1.18)
- def test_stopiteration_wrapping_context(self):
def f():[](#l1.21)
raise StopIteration[](#l1.22)
def g():[](#l1.23)
yield f()[](#l1.24)
try:[](#l1.26)
next(g())[](#l1.27)
except RuntimeError as exc:[](#l1.28)
self.assertIs(type(exc.__cause__), StopIteration)[](#l1.29)
self.assertIs(type(exc.__context__), StopIteration)[](#l1.30)
self.assertTrue(exc.__suppress_context__)[](#l1.31)
else:[](#l1.32)
self.fail('__cause__, __context__, or __suppress_context__ '[](#l1.33)
'were not properly set')[](#l1.34)