mirror of
https://github.com/Stone-Red-Code/dvc.git
synced 2026-11-02 07:18:25 +01:00
fix dvc.yaml filepath in error message when reading from git revisions (#10847)
This commit is contained in:
@@ -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):
|
||||
|
||||
Reference in New Issue
Block a user