(self, caplog, dt)
| 148 | assert expected == formatter.format(caplog.records[0]) |
| 149 | |
| 150 | def test_nested_exceptions(self, caplog, dt): |
| 151 | with caplog.at_level(logging.DEBUG, logger="dvc"): |
| 152 | try: |
| 153 | raise Exception("first") |
| 154 | except Exception as exc: # noqa: BLE001 |
| 155 | try: |
| 156 | raise DvcException("second") from exc |
| 157 | except DvcException: |
| 158 | stack_trace = traceback.format_exc() |
| 159 | logger.exception("message") |
| 160 | |
| 161 | expected = ( |
| 162 | "{red}{datetime}{nc} " |
| 163 | "{red}ERROR{nc}: message - second: first\n" |
| 164 | "{stack_trace}".format( |
| 165 | stack_trace=stack_trace, |
| 166 | **colors, |
| 167 | datetime=dt, |
| 168 | ) |
| 169 | ) |
| 170 | assert expected == formatter.format(caplog.records[0]) |
| 171 | assert "Exception: first" in stack_trace |
| 172 | assert "dvc.exceptions.DvcException: second" in stack_trace |
| 173 | |
| 174 | def test_progress_awareness(self, mocker, capsys, caplog): |
| 175 | from dvc.progress import Tqdm |
nothing calls this directly
no test coverage detected