Iterate over Cartesian product of *args, and if an exception is raised, add information of the current iterate.
(*args)
| 42 | |
| 43 | @contextlib.contextmanager |
| 44 | def exc_iter(*args): |
| 45 | """ |
| 46 | Iterate over Cartesian product of *args, and if an exception is raised, |
| 47 | add information of the current iterate. |
| 48 | """ |
| 49 | |
| 50 | value = [None] |
| 51 | |
| 52 | def iterate(): |
| 53 | for v in itertools.product(*args): |
| 54 | value[0] = v |
| 55 | yield v |
| 56 | |
| 57 | try: |
| 58 | yield iterate() |
| 59 | except Exception: |
| 60 | import traceback |
| 61 | msg = "At: %r\n%s" % (repr(value[0]), |
| 62 | traceback.format_exc()) |
| 63 | raise AssertionError(msg) |
| 64 | |
| 65 | |
| 66 | def test_safe_binop(): |
no test coverage detected