| 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 |
| 176 | |
| 177 | mocker.patch("sys.stdout.isatty", return_value=True) |
| 178 | with Tqdm(total=100, desc="progress") as pbar: |
| 179 | pbar.update() |
| 180 | |
| 181 | # logging an invisible message should not break |
| 182 | # the progress bar output |
| 183 | with caplog.at_level(logging.INFO, logger="dvc"): |
| 184 | debug_record = logging.LogRecord( |
| 185 | name="dvc", |
| 186 | level=logging.DEBUG, |
| 187 | pathname=__name__, |
| 188 | lineno=1, |
| 189 | msg="debug", |
| 190 | args=(), |
| 191 | exc_info=None, |
| 192 | ) |
| 193 | |
| 194 | formatter.format(debug_record) |
| 195 | captured = capsys.readouterr() |
| 196 | assert not captured.out |
| 197 | |
| 198 | # when the message is actually visible |
| 199 | with caplog.at_level(logging.INFO, logger="dvc"): |
| 200 | logger.info("some info") |
| 201 | captured = capsys.readouterr() |
| 202 | assert not captured.out |
| 203 | |
| 204 | |
| 205 | def test_handlers(): |