diff --git a/monkey/tests/unit_tests/monkey_island/cc/setup/test_process_runner.py b/monkey/tests/unit_tests/monkey_island/cc/setup/test_process_runner.py index f4aec0ba8..5aa4e697b 100644 --- a/monkey/tests/unit_tests/monkey_island/cc/setup/test_process_runner.py +++ b/monkey/tests/unit_tests/monkey_island/cc/setup/test_process_runner.py @@ -1,22 +1,26 @@ import os +import pytest + from monkey_island.cc.setup.mongo_process_runner import MongoDbRunner +TEST_DIR_NAME = "test_dir" -def test_create_db_dir(monkeypatch, tmpdir): - test_dir_name = "test_dir" - monkeypatch.setattr("monkey_island.cc.setup.mongo_process_runner.DB_DIR_NAME", test_dir_name) - expected_path = os.path.join(tmpdir, test_dir_name) +@pytest.fixture +def expected_path(monkeypatch, tmpdir): + monkeypatch.setattr("monkey_island.cc.setup.mongo_process_runner.DB_DIR_NAME", TEST_DIR_NAME) + expected_path = os.path.join(tmpdir, TEST_DIR_NAME) + return expected_path + + +def test_create_db_dir(monkeypatch, tmpdir, expected_path): db_path = MongoDbRunner(tmpdir, tmpdir)._create_db_dir() assert os.path.isdir(expected_path) assert db_path == expected_path -def test_create_db_dir__already_created(monkeypatch, tmpdir): - test_dir_name = "test_dir" - monkeypatch.setattr("monkey_island.cc.setup.mongo_process_runner.DB_DIR_NAME", test_dir_name) - expected_path = os.path.join(tmpdir, test_dir_name) +def test_create_db_dir__already_created(monkeypatch, tmpdir, expected_path): os.mkdir(expected_path) db_path = MongoDbRunner(tmpdir, tmpdir)._create_db_dir()