From 787ea9cd31993458d0380f05bcf0a68bf68dde09 Mon Sep 17 00:00:00 2001 From: "Mr. Outis" Date: Wed, 27 Nov 2019 12:37:11 -0600 Subject: [PATCH] tests: set temporary global config --- tests/unit/test_analytics.py | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/tests/unit/test_analytics.py b/tests/unit/test_analytics.py index e8acf1c5f..2c443095c 100644 --- a/tests/unit/test_analytics.py +++ b/tests/unit/test_analytics.py @@ -5,7 +5,15 @@ import mock from dvc import analytics -def test_collect(): +@pytest.fixture +def tmp_global_config(tmp_path): + with mock.patch( + "dvc.config.Config.get_global_config_dir", return_value=tmp_path + ): + yield + + +def test_collect(tmp_global_config): report = analytics.collect(return_code=0) assert report["cmd_return_code"] == 0 @@ -49,11 +57,8 @@ def test_is_enabled(dvc_repo, config, result, monkeypatch): assert result == analytics.is_enabled() -def test_find_or_create_user_id(tmp_path): - with mock.patch( - "dvc.config.Config.get_global_config_dir", return_value=tmp_path - ): - created = analytics.find_or_create_user_id() - found = analytics.find_or_create_user_id() +def test_find_or_create_user_id(tmp_global_config): + created = analytics.find_or_create_user_id() + found = analytics.find_or_create_user_id() assert created == found