File tree Expand file tree Collapse file tree 2 files changed +23
-0
lines changed
Expand file tree Collapse file tree 2 files changed +23
-0
lines changed Original file line number Diff line number Diff line change 11using System ;
2+ using System . Collections ;
3+ using System . Collections . Generic ;
24
35namespace Python . Test
46{
@@ -54,6 +56,13 @@ public static bool ThrowException()
5456 throw new OverflowException ( "error" ) ;
5557 }
5658
59+ public static IEnumerable < int > ThrowExceptionInIterator ( )
60+ {
61+ yield return 1 ;
62+ yield return 2 ;
63+ throw new OverflowException ( "error" ) ;
64+ }
65+
5766 public static void ThrowChainedExceptions ( )
5867 {
5968 try
Original file line number Diff line number Diff line change @@ -345,3 +345,17 @@ def test_chained_exceptions():
345345 assert exc .Message == msg
346346 assert exc .__cause__ == exc .InnerException
347347 exc = exc .__cause__
348+
349+ def test_iteration_exception ():
350+ from Python .Test import ExceptionTest
351+ from System import OverflowException
352+
353+ val = ExceptionTest .ThrowExceptionInIterator ().__iter__ ()
354+ assert next (val ) == 1
355+ assert next (val ) == 2
356+ with pytest .raises (OverflowException ) as cm :
357+ next (val )
358+
359+ exc = cm .value
360+
361+ assert isinstance (exc , OverflowException )
You can’t perform that action at this time.
0 commit comments