diff --git a/monkey/tests/unit_tests/common/utils/test_common_file_utils.py b/monkey/tests/unit_tests/common/utils/test_common_file_utils.py index b0f7c5862..226a403b8 100644 --- a/monkey/tests/unit_tests/common/utils/test_common_file_utils.py +++ b/monkey/tests/unit_tests/common/utils/test_common_file_utils.py @@ -3,15 +3,15 @@ import os 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") - 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 -def test_expand_vars(mock_home_env): +def test_expand_vars(patched_home_env): 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 diff --git a/monkey/tests/unit_tests/conftest.py b/monkey/tests/unit_tests/conftest.py new file mode 100644 index 000000000..a779d65fd --- /dev/null +++ b/monkey/tests/unit_tests/conftest.py @@ -0,0 +1,8 @@ +import pytest + + +@pytest.fixture +def patched_home_env(monkeypatch, tmpdir): + monkeypatch.setenv("HOME", str(tmpdir)) + + return tmpdir diff --git a/monkey/tests/unit_tests/monkey_island/conftest.py b/monkey/tests/unit_tests/monkey_island/conftest.py index 538576aef..2ccecd616 100644 --- a/monkey/tests/unit_tests/monkey_island/conftest.py +++ b/monkey/tests/unit_tests/monkey_island/conftest.py @@ -9,13 +9,6 @@ def server_configs_dir(data_for_tests_dir): 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 def create_empty_tmp_file(tmpdir: str) -> Callable: def inner(file_name: str):