mirror of
https://github.com/Stone-Red-Code/dvc.git
synced 2026-11-01 23:08:43 +01:00
* [pre-commit.ci] pre-commit autoupdate updates: - [github.com/charliermarsh/ruff-pre-commit: v0.0.254 → v0.0.257](https://github.com/charliermarsh/ruff-pre-commit/compare/v0.0.254...v0.0.257) - [github.com/codespell-project/codespell: v2.2.2 → v2.2.4](https://github.com/codespell-project/codespell/compare/v2.2.2...v2.2.4) * pre-commit: fix ruff errors * pre-commit: fix flake8 --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: David de la Iglesia Castro <[email protected]>
49 lines
1.4 KiB
Python
49 lines
1.4 KiB
Python
import logging
|
|
|
|
from dvc.progress import Tqdm
|
|
from dvc.utils import env2bool
|
|
|
|
|
|
def test_quiet_logging(caplog, capsys):
|
|
with caplog.at_level(logging.CRITICAL, logger="dvc"):
|
|
for _ in Tqdm(range(10)):
|
|
pass
|
|
out_err = capsys.readouterr()
|
|
assert not out_err.out
|
|
assert not out_err.err
|
|
|
|
|
|
def test_quiet_logging_disable_false(caplog, capsys, mocker):
|
|
# simulate interactive terminal
|
|
mocker.patch("sys.stdout.isatty", return_value=True)
|
|
with caplog.at_level(logging.CRITICAL, logger="dvc"):
|
|
for _ in Tqdm(range(10), disable=False):
|
|
pass
|
|
out_err = capsys.readouterr()
|
|
assert not out_err.out
|
|
assert not out_err.err
|
|
|
|
|
|
def test_quiet_notty(caplog, capsys):
|
|
with caplog.at_level(logging.INFO, logger="dvc"):
|
|
for _ in Tqdm(range(10)):
|
|
pass
|
|
out_err = capsys.readouterr()
|
|
assert not out_err.out
|
|
if env2bool("DVC_IGNORE_ISATTY"):
|
|
assert "0/10" in out_err.err
|
|
else:
|
|
assert not out_err.err
|
|
|
|
|
|
def test_default(caplog, capsys, mocker):
|
|
# simulate interactive terminal
|
|
mocker.patch("sys.stdout.isatty", return_value=True)
|
|
with caplog.at_level(logging.INFO, logger="dvc"):
|
|
for _ in Tqdm(range(10)):
|
|
pass
|
|
|
|
out_err = capsys.readouterr()
|
|
assert not out_err.out
|
|
assert "0/10" in out_err.err
|