From dff21fce37c4a44d14cb8ba2bc43bcc915534c28 Mon Sep 17 00:00:00 2001 From: Abhas Bhattacharya Date: Fri, 25 Dec 2015 18:26:27 +0530 Subject: [PATCH] Use env REDIS_ARGS, REDIS_PATH and port in caps --- pytest_gui_status/status_plugin/plugin.py | 15 +++++++++------ tests/test_plugin/test_plugin.py | 8 ++++---- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/pytest_gui_status/status_plugin/plugin.py b/pytest_gui_status/status_plugin/plugin.py index e45f5af..285888e 100644 --- a/pytest_gui_status/status_plugin/plugin.py +++ b/pytest_gui_status/status_plugin/plugin.py @@ -8,17 +8,19 @@ import psutil import datetime -env_redis_port = os.environ.get("pytest_status_port") +env_redis_port = os.environ.get("PYTEST_STATUS_PORT") if env_redis_port: REDIS_PORT = int(env_redis_port) else: REDIS_PORT = 5946 -if os.environ.get("TRAVIS") == "true": - command_redis_server_gen = "redis-server --port {port}" -else: - command_redis_server_gen = "redis-server --port {port} --maxheap 20MB" -command_redis_server = command_redis_server_gen.format(port=REDIS_PORT) +REDIS_PATH = os.environ.get("REDIS_PATH") or "redis-server" +REDIS_ARGS = os.environ.get("REDIS_ARGS") or "" + +command_redis_server_gen = "{REDIS_PATH} --port {REDIS_PORT} {REDIS_ARGS}" +command_redis_server = command_redis_server_gen.format(REDIS_PATH=REDIS_PATH, + REDIS_ARGS=REDIS_ARGS, + REDIS_PORT=REDIS_PORT) command_status_gui_gen = "pytest_gui_status \"{norm_dir_name}\"" @@ -252,6 +254,7 @@ def pytest_configure(config): def pytest_sessionstart(session): config = session.config + PYTEST_DATA.data["dir_name_start"] = str(session.startdir) Helpers.on_start(PYTEST_DATA.data["dir_name_start"]) diff --git a/tests/test_plugin/test_plugin.py b/tests/test_plugin/test_plugin.py index 1839e09..9cb19be 100644 --- a/tests/test_plugin/test_plugin.py +++ b/tests/test_plugin/test_plugin.py @@ -39,7 +39,7 @@ def create_temp_case(case_name, path_tmpdir=None): @patch.dict("os.environ", - {"pytest_status_port": str(REDIS_TEST_PORT)}) + {"PYTEST_STATUS_PORT": str(REDIS_TEST_PORT)}) def test_whole_1(tmpdir): ''' Integration test @@ -49,7 +49,7 @@ def test_whole_1(tmpdir): path_case = create_temp_case("case_1", tmpdir) os.chdir(path_case) - assert(os.environ.get("pytest_status_port") == str(REDIS_TEST_PORT)) + assert(os.environ.get("PYTEST_STATUS_PORT") == str(REDIS_TEST_PORT)) popen_pytest = subprocess.Popen(["py.test", "-s"], shell=True) popen_pytest.wait() @@ -68,7 +68,7 @@ def test_whole_1(tmpdir): @patch.dict("os.environ", - {"pytest_status_port": str(REDIS_TEST_PORT)}) + {"PYTEST_STATUS_PORT": str(REDIS_TEST_PORT)}) def test_whole_2(tmpdir): ''' Integration test @@ -93,7 +93,7 @@ def test_whole_2(tmpdir): @patch.dict("os.environ", - {"pytest_status_port": str(REDIS_TEST_PORT)}) + {"PYTEST_STATUS_PORT": str(REDIS_TEST_PORT)}) def test_intermediate_1(tmpdir): ''' Integration test