mirror of
https://github.com/Stone-Red-Code/dvc.git
synced 2026-11-09 15:28:26 +01:00
diff: fix missing key bug (#6720)
This commit is contained in:
committed by
David de la Iglesia Castro
parent
6bb3794f52
commit
fc3f3ca8d7
@@ -128,7 +128,7 @@ class CmdDiff(CmdBase):
|
||||
show_hash = self.args.show_hash
|
||||
hide_missing = self.args.b_rev or self.args.hide_missing
|
||||
if hide_missing:
|
||||
del diff["not in cache"]
|
||||
diff.pop("not in cache", None)
|
||||
|
||||
for key, entries in diff.items():
|
||||
entries = sorted(
|
||||
|
||||
@@ -204,20 +204,31 @@ def test_diff_show_markdown_and_hash(mocker, show_hash):
|
||||
mock_show_markdown.assert_called_once_with(diff, show_hash, False)
|
||||
|
||||
|
||||
def test_no_changes(mocker, capsys):
|
||||
args = parse_args(["diff", "--json"])
|
||||
@pytest.mark.parametrize(
|
||||
"opts",
|
||||
(
|
||||
[],
|
||||
["a_rev", "b_rev"],
|
||||
["--targets", "."],
|
||||
["--hide-missing"],
|
||||
),
|
||||
)
|
||||
@pytest.mark.parametrize(
|
||||
"show, expected",
|
||||
(
|
||||
([], ""),
|
||||
(["--json"], "{}"),
|
||||
(["--md"], "| Status | Path |\n|----------|--------|"),
|
||||
),
|
||||
)
|
||||
def test_no_changes(mocker, capsys, opts, show, expected):
|
||||
args = parse_args(["diff", *opts, *show])
|
||||
cmd = args.func(args)
|
||||
mocker.patch("dvc.repo.Repo.diff", return_value={})
|
||||
|
||||
assert 0 == cmd.run()
|
||||
out, _ = capsys.readouterr()
|
||||
assert "{}" in out
|
||||
|
||||
args = parse_args(["diff"])
|
||||
cmd = args.func(args)
|
||||
assert 0 == cmd.run()
|
||||
out, _ = capsys.readouterr()
|
||||
assert not out
|
||||
assert expected == out.strip()
|
||||
|
||||
|
||||
def test_show_markdown(capsys):
|
||||
|
||||
Reference in New Issue
Block a user