()
| 136 | |
| 137 | |
| 138 | def test_nested_exception(): |
| 139 | console = Console(width=100, file=io.StringIO()) |
| 140 | value_error_message = "ValueError because of ZeroDivisionError" |
| 141 | |
| 142 | try: |
| 143 | try: |
| 144 | 1 / 0 |
| 145 | except ZeroDivisionError: |
| 146 | raise ValueError(value_error_message) |
| 147 | except Exception: |
| 148 | console.print_exception() |
| 149 | exception_text = console.file.getvalue() |
| 150 | |
| 151 | text_should_contain = [ |
| 152 | value_error_message, |
| 153 | "ZeroDivisionError", |
| 154 | "ValueError", |
| 155 | "During handling of the above exception", |
| 156 | ] |
| 157 | |
| 158 | for msg in text_should_contain: |
| 159 | assert msg in exception_text |
| 160 | |
| 161 | # ZeroDivisionError should come before ValueError |
| 162 | assert exception_text.find("ZeroDivisionError") < exception_text.find("ValueError") |
| 163 | |
| 164 | |
| 165 | def test_caused_exception(): |
nothing calls this directly
no test coverage detected