def test_open_dirty_no_hash(tmp_dir, dvc): tmp_dir.gen("file", "file") (tmp_dir / "file.dvc").write_text("outs:\n- path: file\n") tree = DvcTree(dvc) with tree.open("file", "r") as fobj: assert fobj.read() == "file"
def test_open_dirty_hash(tmp_dir, dvc): tmp_dir.dvc_gen("file", "file") (tmp_dir / "file").write_text("something") tree = DvcTree(dvc) with tree.open("file", "r") as fobj: assert fobj.read() == "something"
def test_open(tmp_dir, dvc): tmp_dir.gen("foo", "foo") dvc.add("foo") (tmp_dir / "foo").unlink() tree = DvcTree(dvc) with tree.open("foo", "r") as fobj: assert fobj.read() == "foo"
def test_open_dirty_hash(tmp_dir, dvc): tmp_dir.dvc_gen("file", "file") (tmp_dir / "file").write_text("something") tree = DvcTree(dvc) with tree.open("file", "r") as fobj: # NOTE: Unlike RepoTree, DvcTree should not # be affected by a dirty workspace. assert fobj.read() == "file"
def test_open_dirty_no_hash(tmp_dir, dvc): tmp_dir.gen("file", "file") (tmp_dir / "file.dvc").write_text("outs:\n- path: file\n") tree = DvcTree(dvc) # NOTE: Unlike RepoTree, DvcTree should not # be affected by a dirty workspace. with pytest.raises(FileNotFoundError): with tree.open("file", "r"): pass
def test_open_in_history(tmp_dir, scm, dvc): tmp_dir.gen("foo", "foo") dvc.add("foo") dvc.scm.add(["foo.dvc", ".gitignore"]) dvc.scm.commit("foo") tmp_dir.gen("foo", "foofoo") dvc.add("foo") dvc.scm.add(["foo.dvc", ".gitignore"]) dvc.scm.commit("foofoo") for rev in dvc.brancher(revs=["HEAD~1"]): if rev == "workspace": continue tree = DvcTree(dvc) with tree.open("foo", "r") as fobj: assert fobj.read() == "foo"