mirror of
https://github.com/Stone-Red-Code/dvc.git
synced 2026-11-01 23:08:43 +01:00
try to reset log-level after setting it (#10800)
This commit is contained in:
+5
-5
@@ -1,7 +1,7 @@
|
||||
import json
|
||||
import os
|
||||
import sys
|
||||
from contextlib import suppress
|
||||
from contextlib import ExitStack, suppress
|
||||
|
||||
import pytest
|
||||
|
||||
@@ -46,10 +46,10 @@ def reset_loglevel(request, caplog):
|
||||
ini_opt = request.config.getini("log_level")
|
||||
|
||||
level = request.config.getoption("--log-level") or ini_opt
|
||||
if level:
|
||||
with caplog.at_level(level.upper(), logger="dvc"):
|
||||
yield
|
||||
else:
|
||||
with ExitStack() as stack:
|
||||
if level:
|
||||
for name in ["dvc", "dvc_data", "dvc_objects"]:
|
||||
stack.enter_context(caplog.at_level(level.upper(), logger=name))
|
||||
yield
|
||||
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@ from copy import deepcopy
|
||||
|
||||
import pytest
|
||||
|
||||
from dvc import env
|
||||
from dvc.annotations import Artifact
|
||||
from dvc.exceptions import ArtifactNotFoundError, InvalidArgumentError
|
||||
from dvc.repo.artifacts import Artifacts, check_name_format
|
||||
@@ -283,7 +284,13 @@ def test_artifacts_download_subrepo(tmp_dir, scm, sub):
|
||||
assert Artifacts.get(".", name, force=True) == result
|
||||
|
||||
|
||||
def test_artifacts_download_studio(tmp_dir, dvc, mocker):
|
||||
def test_artifacts_download_studio(monkeypatch, tmp_dir, dvc, mocker, tmp_path_factory):
|
||||
global_config_dir = tmp_path_factory.mktemp("global_config")
|
||||
monkeypatch.setenv(env.DVC_GLOBAL_CONFIG_DIR, str(global_config_dir))
|
||||
# reset config to ensure it picks up the new global config
|
||||
dvc.__dict__.pop("config")
|
||||
assert dvc.config.files["global"] == os.fspath(global_config_dir / "config")
|
||||
|
||||
with dvc.config.edit("global") as conf:
|
||||
conf["studio"]["token"] = "mytoken"
|
||||
|
||||
|
||||
@@ -238,9 +238,9 @@ def test_push_pull_unsupported(tmp_dir, dvc, mocker, run_copy, local_remote, cap
|
||||
mocker.patch.object(
|
||||
dvc.cloud, "get_remote_odb", side_effect=RunCacheNotSupported("foo")
|
||||
)
|
||||
with caplog.at_level(logging.DEBUG):
|
||||
with caplog.at_level(logging.DEBUG, logger="dvc"):
|
||||
dvc.push(run_cache=True)
|
||||
assert "failed to push run cache" in caplog.text
|
||||
with caplog.at_level(logging.DEBUG):
|
||||
with caplog.at_level(logging.DEBUG, logger="dvc"):
|
||||
dvc.pull(run_cache=True)
|
||||
assert "failed to pull run cache" in caplog.text
|
||||
|
||||
@@ -29,7 +29,7 @@ def test_post_to_studio(
|
||||
monkeypatch.setenv(DVC_STUDIO_REPO_URL, "STUDIO_REPO_URL")
|
||||
monkeypatch.setenv(DVC_STUDIO_TOKEN, "STUDIO_TOKEN")
|
||||
monkeypatch.setenv(DVC_STUDIO_URL, "https://0.0.0.0")
|
||||
monkeypatch.setenv(DVC_STUDIO_OFFLINE, offline)
|
||||
monkeypatch.setenv(DVC_STUDIO_OFFLINE, str(offline))
|
||||
if dvc_exp_git_remote:
|
||||
monkeypatch.setenv(DVC_EXP_GIT_REMOTE, dvc_exp_git_remote)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user