Tests: Fix failing expand_path() tests

This commit is contained in:
Mike Salvatore 2021-07-06 11:29:42 -04:00
parent 8dd1aa25ac
commit 5ac574bd17
3 changed files with 12 additions and 11 deletions

View File

@ -3,15 +3,15 @@ import os
from common.utils.file_utils import expand_path from common.utils.file_utils import expand_path
def test_expand_user(mock_home_env): def test_expand_user(patched_home_env):
input_path = os.path.join("~", "test") input_path = os.path.join("~", "test")
expected_path = os.path.join(mock_home_env, "test") expected_path = os.path.join(patched_home_env, "test")
assert expand_path(input_path) == expected_path assert expand_path(input_path) == expected_path
def test_expand_vars(mock_home_env): def test_expand_vars(patched_home_env):
input_path = os.path.join("$HOME", "test") input_path = os.path.join("$HOME", "test")
expected_path = os.path.join(mock_home_env, "test") expected_path = os.path.join(patched_home_env, "test")
assert expand_path(input_path) == expected_path assert expand_path(input_path) == expected_path

View File

@ -0,0 +1,8 @@
import pytest
@pytest.fixture
def patched_home_env(monkeypatch, tmpdir):
monkeypatch.setenv("HOME", str(tmpdir))
return tmpdir

View File

@ -9,13 +9,6 @@ def server_configs_dir(data_for_tests_dir):
return os.path.join(data_for_tests_dir, "server_configs") return os.path.join(data_for_tests_dir, "server_configs")
@pytest.fixture
def patched_home_env(monkeypatch, tmpdir):
monkeypatch.setenv("HOME", str(tmpdir))
return tmpdir
@pytest.fixture @pytest.fixture
def create_empty_tmp_file(tmpdir: str) -> Callable: def create_empty_tmp_file(tmpdir: str) -> Callable:
def inner(file_name: str): def inner(file_name: str):