mirror of
https://github.com/Stone-Red-Code/dvc.git
synced 2026-11-02 07:18:25 +01:00
config: don't look for .dvc dir implicitly
Currently if dvc_dir doesn't exists (e.g. we are creating an uninitialized repo), config will try looking for `.dvc` dir in the current directory, which might be inside of another dvc repository resulting in mixed configs. Use explicit `from_cwd` method to make `Config` try to find repo configs if available to avoid the usage mixup.
This commit is contained in:
@@ -245,7 +245,7 @@ def test_merging_two_levels(dvc):
|
||||
|
||||
def test_config_loads_without_error_for_non_dvc_repo(tmp_dir):
|
||||
# regression testing for https://github.com/iterative/dvc/issues/3328
|
||||
Config(validate=True)
|
||||
Config.from_cwd(validate=True)
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
@@ -284,7 +284,7 @@ def test_config_gdrive_fields(tmp_dir, dvc):
|
||||
"profile": "myprofile",
|
||||
}
|
||||
|
||||
Config(validate=True)
|
||||
Config.from_cwd(validate=True)
|
||||
|
||||
|
||||
def test_config_remote(tmp_dir, dvc, capsys):
|
||||
|
||||
@@ -25,7 +25,7 @@ def test_get_fs(tmp_dir, scm):
|
||||
tmp_dir.scm_gen("foo", "foo", commit="add foo")
|
||||
|
||||
fs = scm.get_fs("master")
|
||||
config = Config(fs=fs)
|
||||
config = Config.from_cwd(fs=fs)
|
||||
|
||||
assert config.fs == fs
|
||||
assert config.wfs != fs
|
||||
@@ -38,7 +38,7 @@ def test_get_fs(tmp_dir, scm):
|
||||
|
||||
|
||||
def test_s3_ssl_verify(tmp_dir, dvc):
|
||||
config = Config(validate=False)
|
||||
config = Config.from_cwd(validate=False)
|
||||
with config.edit() as conf:
|
||||
conf["remote"]["remote-name"] = {"url": "s3://bucket/dvc"}
|
||||
|
||||
@@ -74,7 +74,7 @@ def test_s3_ssl_verify(tmp_dir, dvc):
|
||||
|
||||
|
||||
def test_load_unicode_error(tmp_dir, dvc, mocker):
|
||||
config = Config(validate=False)
|
||||
config = Config.from_cwd(validate=False)
|
||||
mocker.patch(
|
||||
"configobj.ConfigObj",
|
||||
side_effect=UnicodeDecodeError("", b"", 0, 0, ""),
|
||||
@@ -87,7 +87,7 @@ def test_load_unicode_error(tmp_dir, dvc, mocker):
|
||||
def test_load_configob_error(tmp_dir, dvc, mocker):
|
||||
from configobj import ConfigObjError
|
||||
|
||||
config = Config(validate=False)
|
||||
config = Config.from_cwd(validate=False)
|
||||
mocker.patch(
|
||||
"configobj.ConfigObj",
|
||||
side_effect=ConfigObjError(),
|
||||
|
||||
Reference in New Issue
Block a user