summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_pep479.py
diff options
context:
space:
mode:
authorYury Selivanov <yselivanov@sprymix.com>2015-05-09 17:53:57 (GMT)
committerYury Selivanov <yselivanov@sprymix.com>2015-05-09 17:53:57 (GMT)
commite9ad5a57d793562ffb4ab37cf420aee5aeb3afbc (patch)
tree11e6ae5985c6eafe71ba528a35b9934b605f1025 /Lib/test/test_pep479.py
parent8170e8c0d12cb9414f3a3d3ca81a447b4afc5f26 (diff)
downloadcpython-e9ad5a57d793562ffb4ab37cf420aee5aeb3afbc.zip
cpython-e9ad5a57d793562ffb4ab37cf420aee5aeb3afbc.tar.gz
cpython-e9ad5a57d793562ffb4ab37cf420aee5aeb3afbc.tar.bz2
Issue 22906: Add test file.
Diffstat (limited to 'Lib/test/test_pep479.py')
-rw-r--r--Lib/test/test_pep479.py34
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
index 0000000..bc235ce
--- /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()