()
| 163 | |
| 164 | |
| 165 | def test_caused_exception(): |
| 166 | console = Console(width=100, file=io.StringIO()) |
| 167 | value_error_message = "ValueError caused by ZeroDivisionError" |
| 168 | |
| 169 | try: |
| 170 | try: |
| 171 | 1 / 0 |
| 172 | except ZeroDivisionError as e: |
| 173 | raise ValueError(value_error_message) from e |
| 174 | except Exception: |
| 175 | console.print_exception() |
| 176 | exception_text = console.file.getvalue() |
| 177 | |
| 178 | text_should_contain = [ |
| 179 | value_error_message, |
| 180 | "ZeroDivisionError", |
| 181 | "ValueError", |
| 182 | "The above exception was the direct cause", |
| 183 | ] |
| 184 | |
| 185 | for msg in text_should_contain: |
| 186 | assert msg in exception_text |
| 187 | |
| 188 | # ZeroDivisionError should come before ValueError |
| 189 | assert exception_text.find("ZeroDivisionError") < exception_text.find("ValueError") |
| 190 | |
| 191 | |
| 192 | def test_filename_with_bracket(): |
nothing calls this directly
no test coverage detected