示例#1
0
    def test_fail_if_hook_exists(self, scm, dvc):
        self._hook("post-checkout").write_text("hook content")

        with pytest.raises(DvcException) as exc_info:
            dvc.install()

        assert escape_ansi(str(exc_info.value)) == (
            "Hook 'post-checkout' already exists. "
            "Please refer to <https://man.dvc.org/install> for more info.")
示例#2
0
def test_stats_on_show_changes_does_not_show_summary(
    tmp_dir, dvc, scm, capsys
):
    tmp_dir.dvc_gen(
        {"dir": {"subdir": {"file": "file"}}, "other": "other"},
        commit="initial",
    )
    scm.checkout("HEAD~")

    assert main(["checkout"]) == 0

    out, _ = capsys.readouterr()
    assert escape_ansi(out).splitlines() == [f"D\tdir{os.sep}", "D\tother"]
示例#3
0
def test_check_updates(mocker, capsys, updater, current, latest, notify):
    mocker.patch("sys.stdout.isatty", return_value=True)

    updater.current = current
    with open(updater.updater_file, "w+") as f:
        json.dump({"version": latest}, f)

    updater.check()
    out, err = capsys.readouterr()
    expected_message = ((f"You are using dvc version {current}; "
                         f"however, version {latest} is available.\n")
                        if notify else "")

    assert expected_message in escape_ansi(err)
    assert not out
示例#4
0
def test_pull_stats(tmp_dir, dvc, capsys, caplog, local_remote):
    tmp_dir.dvc_gen({"foo": "foo", "bar": "bar"})
    dvc.push()
    clean(["foo", "bar"], dvc)
    (tmp_dir / "bar").write_text("foobar")

    assert main(["pull", "--force"]) == 0

    out, _ = capsys.readouterr()
    out = escape_ansi(out)
    assert "M\tbar" in out
    assert "A\tfoo" in out
    assert "2 files fetched" in caplog.text
    assert "1 file added" in caplog.text
    assert "1 file modified" in caplog.text
    with caplog.at_level(level=logging.INFO, logger="dvc"):
        main(["pull"])
    assert "Everything is up to date." in caplog.text
示例#5
0
 def _assert_output(stats, expected_outs):
     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