From e8c6f338bf8bb61f630803e937b3bc022b5c0325 Mon Sep 17 00:00:00 2001 From: Abhas Bhattacharya Date: Sun, 3 Jan 2016 16:39:07 +0530 Subject: [PATCH] Mock htmlpy in gui_tests as it requires pyside gui_tests currently dont require anything from htmlpy, only test redis fail cases --- .travis.yml | 1 - tests/test_plugin/test_gui.py | 13 ++++++++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 0051392..460a4ab 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,7 +5,6 @@ addons: apt: packages: - redis-server - - python-pyside python: # major versions, test first diff --git a/tests/test_plugin/test_gui.py b/tests/test_plugin/test_gui.py index b6a1d36..e3892bb 100644 --- a/tests/test_plugin/test_gui.py +++ b/tests/test_plugin/test_gui.py @@ -1,5 +1,4 @@ import pytest_gui_status.status_plugin.plugin as status_plugin -import pytest_gui_status.status_gui.gui_backend as gui_backend from mock import patch, MagicMock import redis @@ -7,11 +6,17 @@ import pytest REDIS_TEST_PORT = status_plugin.REDIS_PORT + 1 +mock_htmlPy_module = MagicMock() +mock_htmlPy_module.Object = object +mock_htmlPy_module.Slot.return_value = (lambda func: func) + @patch.dict("os.environ", {"PYTEST_STATUS_PORT": str(REDIS_TEST_PORT)}) +@patch.dict("sys.modules", {"htmlPy": mock_htmlPy_module}) def test_redis_fail_1(tmpdir): # load new redis port + import pytest_gui_status.status_gui.gui_backend as gui_backend reload(gui_backend) reload(status_plugin) @@ -36,8 +41,10 @@ def test_redis_fail_1(tmpdir): @patch.dict("os.environ", {"PYTEST_STATUS_PORT": str(REDIS_TEST_PORT)}) +@patch.dict("sys.modules", {"htmlPy": mock_htmlPy_module}) def test_redis_fail_2(tmpdir): # load new redis port + import pytest_gui_status.status_gui.gui_backend as gui_backend reload(gui_backend) reload(status_plugin) @@ -64,8 +71,10 @@ def test_redis_fail_2(tmpdir): @patch.dict("os.environ", {"PYTEST_STATUS_PORT": str(REDIS_TEST_PORT)}) +@patch.dict("sys.modules", {"htmlPy": mock_htmlPy_module}) def test_redis_fail_3(tmpdir): # load new redis port + import pytest_gui_status.status_gui.gui_backend as gui_backend reload(gui_backend) reload(status_plugin) @@ -93,8 +102,10 @@ def test_redis_fail_3(tmpdir): @patch.dict("os.environ", {"PYTEST_STATUS_PORT": str(REDIS_TEST_PORT)}) +@patch.dict("sys.modules", {"htmlPy": mock_htmlPy_module}) def test_redis_fail_4(tmpdir): # load new redis port + import pytest_gui_status.status_gui.gui_backend as gui_backend reload(gui_backend) reload(status_plugin)