mirror of
https://github.com/Stone-Red-Code/dvc.git
synced 2026-11-02 07:18:25 +01:00
For example, when `dvc import`ing something, dvc won't see stuff declared in system and global configs, because GitTree doesn't see stuff that is outside of the git repo. Discord context: https://discordapp.com/channels/485586884165107732/563406153334128681/740543492417126521
36 lines
930 B
Python
36 lines
930 B
Python
import os
|
|
|
|
import pytest
|
|
|
|
from dvc.config import Config
|
|
from dvc.tree.local import LocalTree
|
|
|
|
|
|
@pytest.mark.parametrize(
|
|
"path, expected",
|
|
[
|
|
("cache", "../cache"),
|
|
(os.path.join("..", "cache"), "../../cache"),
|
|
(os.getcwd(), os.getcwd().replace("\\", "/")),
|
|
("ssh://some/path", "ssh://some/path"),
|
|
],
|
|
)
|
|
def test_to_relpath(path, expected):
|
|
assert Config._to_relpath(os.path.join(".", "config"), path) == expected
|
|
|
|
|
|
def test_get_tree(tmp_dir, scm):
|
|
tmp_dir.scm_gen("foo", "foo", commit="add foo")
|
|
|
|
tree = scm.get_tree("master")
|
|
config = Config(tree=tree)
|
|
|
|
assert config.tree == tree
|
|
assert config.wtree != tree
|
|
assert isinstance(config.wtree, LocalTree)
|
|
|
|
assert config._get_tree("repo") == tree
|
|
assert config._get_tree("local") == config.wtree
|
|
assert config._get_tree("global") == config.wtree
|
|
assert config._get_tree("system") == config.wtree
|