Extracted home environment mocking into a reusable fixture and added a todo, to move it to our fixture list

This commit is contained in:
VakarisZ 2021-02-24 10:07:26 +02:00 committed by Mike Salvatore
parent ef1ef3475b
commit 64018eb373
1 changed files with 6 additions and 4 deletions

View File

@ -1,6 +1,8 @@
import logging
import os
import pytest
from monkey_island.cc.consts import MONKEY_ISLAND_ABS_PATH
from monkey_island.cc.island_logger import json_setup_logging
@ -9,16 +11,16 @@ TEST_LOGGER_CONFIG_PATH = os.path.join(
)
def set_home_env(monkeypatch, tmpdir):
# TODO move into monkey/monkey_island/cc/test_common/fixtures after rebase/backmerge
@pytest.fixture
def mock_home_env(monkeypatch, tmpdir):
monkeypatch.setenv("HOME", str(tmpdir))
def test_expanduser_filename(monkeypatch, tmpdir):
def test_expanduser_filename(mock_home_env, tmpdir):
INFO_LOG = os.path.join(tmpdir, "info.log")
TEST_STRING = "Hello, Monkey!"
set_home_env(monkeypatch, tmpdir)
json_setup_logging(TEST_LOGGER_CONFIG_PATH)
logger = logging.getLogger("TestLogger")