| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 25e66f0 commit 31a4482
2 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,4 +1,6 @@ | |||
| 1 | 1 | using System; | |
| 2 | + using System.Collections; | ||
| 3 | + using System.Collections.Generic; | ||
| 2 | 4 | ||
| 3 | 5 | namespace Python.Test | |
| 4 | 6 | { | |
@@ -54,6 +56,13 @@ public static bool ThrowException() | |||
| 54 | 56 | throw new OverflowException("error"); | |
| 55 | 57 | } | |
| 56 | 58 | ||
| 59 | + public static IEnumerable<int> ThrowExceptionInIterator() | ||
| 60 | + { | ||
| 61 | + yield return 1; | ||
| 62 | + yield return 2; | ||
| 63 | + throw new OverflowException("error"); | ||
| 64 | + } | ||
| 65 | + | ||
| 57 | 66 | public static void ThrowChainedExceptions() | |
| 58 | 67 | { | |
| 59 | 68 | try | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -345,3 +345,17 @@ def test_chained_exceptions(): | |||
| 345 | 345 | assert exc.Message == msg | |
| 346 | 346 | assert exc.__cause__ == exc.InnerException | |
| 347 | 347 | 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) | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments