fix dvc.yaml filepath in error message when reading from git revisions (#10847)

This commit is contained in:
skshetry
2025-08-16 13:44:48 +00:00
committed by GitHub
parent 9b5ee43ce1
commit d142d0d6af
2 changed files with 32 additions and 18 deletions
+8 -4
View File
@@ -1,4 +1,4 @@
import os
from os import curdir, pardir, sep
import pytest
from ruamel.yaml import __with_libyaml__ as ruamel_clib
@@ -372,18 +372,22 @@ def test_on_revision(
assert expected.format(short_rev=scm.get_rev()[:7]) in err
def test_make_relpath(tmp_dir, monkeypatch):
def test_make_relpath(tmp_dir, dvc, scm, monkeypatch):
from dvc.utils.strictyaml import make_relpath
gitfs = scm.get_fs("HEAD")
path = tmp_dir / "dvc.yaml"
expected_path = "./dvc.yaml" if os.name == "posix" else ".\\dvc.yaml"
expected_path = curdir + sep + "dvc.yaml"
assert make_relpath(path) == expected_path
assert make_relpath("/dvc.yaml", gitfs) == expected_path
(tmp_dir / "dir").mkdir(exist_ok=True)
monkeypatch.chdir("dir")
gitfs.chdir("/dir")
expected_path = "../dvc.yaml" if os.name == "posix" else "..\\dvc.yaml"
expected_path = pardir + sep + "dvc.yaml"
assert make_relpath(path) == expected_path
assert make_relpath("/dvc.yaml", gitfs) == expected_path
def test_fallback_exception_message(tmp_dir, dvc, mocker, caplog):