[Python-checkins] cpython: Issue 22906: Add test file.
yury.selivanov
python-checkins at python.org
Sat May 9 19:54:02 CEST 2015
https://hg.python.org/cpython/rev/d15c26085591
changeset: 95933:d15c26085591
user: Yury Selivanov <yselivanov at sprymix.com>
date: Sat May 09 13:53:57 2015 -0400
summary:
Issue 22906: Add test file.
files:
Lib/test/test_pep479.py | 34 +++++++++++++++++++++++++++++
1 files changed, 34 insertions(+), 0 deletions(-)
diff --git a/Lib/test/test_pep479.py b/Lib/test/test_pep479.py
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():
+ raise StopIteration
+ def g():
+ yield f()
+ with self.assertRaisesRegex(RuntimeError,
+ "generator raised StopIteration"):
+ next(g())
+
+ def test_stopiteration_wrapping_context(self):
+ def f():
+ raise StopIteration
+ def g():
+ yield f()
+
+ try:
+ next(g())
+ except RuntimeError as exc:
+ self.assertIs(type(exc.__cause__), StopIteration)
+ self.assertIs(type(exc.__context__), StopIteration)
+ self.assertTrue(exc.__suppress_context__)
+ else:
+ self.fail('__cause__, __context__, or __suppress_context__ '
+ 'were not properly set')
+
+
+if __name__ == '__main__':
+ unittest.main()
--
Repository URL: https://hg.python.org/cpython
More information about the Python-checkins
mailing list