ui: migrate checkout to ui.write (#6028)

This commit is contained in:
Saugat Pachhai
2021-05-18 13:55:11 +02:00
committed by GitHub
parent 9a5b7251b3
commit 789faa4f11
4 changed files with 31 additions and 44 deletions
+7 -9
View File
@@ -1,7 +1,6 @@
import logging
from dvc.cli import parse_args
from dvc.command.checkout import CmdCheckout, log_changes
from tests.func.parsing.test_errors import escape_ansi
def test_checkout(tmp_dir, dvc, mocker):
@@ -23,7 +22,7 @@ def test_checkout(tmp_dir, dvc, mocker):
)
def test_log_changes(caplog):
def test_log_changes(capsys):
stats = {
"added": ["file1", "dir1/"],
"deleted": ["dir2/"],
@@ -33,12 +32,11 @@ def test_log_changes(caplog):
from itertools import zip_longest
def _assert_output(stats, expected_outs):
with caplog.at_level(logging.INFO, logger="dvc"):
caplog.clear()
log_changes(stats)
actual_output = caplog.text.splitlines()
for out, line in zip_longest(expected_outs, actual_output):
assert out in line
log_changes(stats)
out, _ = capsys.readouterr()
actual_output = escape_ansi(out).splitlines()
for out, line in zip_longest(expected_outs, actual_output):
assert out in line
_assert_output(stats, ["M\tfile2", "A\tfile1", "A\tdir1/", "D\tdir2/"])