diff --git a/masakarimonitors/processmonitor/process.py b/masakarimonitors/processmonitor/process.py index 66e03bb..0149309 100644 --- a/masakarimonitors/processmonitor/process.py +++ b/masakarimonitors/processmonitor/process.py @@ -35,7 +35,7 @@ class ProcessmonitorManager(manager.Manager): def _load_process_list(self): try: - process_list = yaml.load(file(CONF.process.process_list_path)) + process_list = yaml.load(open(CONF.process.process_list_path)) LOG.debug("Loaded process list. %s" % process_list) return process_list diff --git a/masakarimonitors/tests/unit/processmonitor/test_process.py b/masakarimonitors/tests/unit/processmonitor/test_process.py index 5f93b44..51be4f5 100644 --- a/masakarimonitors/tests/unit/processmonitor/test_process.py +++ b/masakarimonitors/tests/unit/processmonitor/test_process.py @@ -78,7 +78,7 @@ class TestProcessmonitorManager(testtools.TestCase): @mock.patch.object(handle_process.HandleProcess, 'start_processes') @mock.patch.object(handle_process.HandleProcess, 'set_process_list') @mock.patch.object(yaml, 'load') - @mock.patch('__builtin__.file') + @mock.patch('six.moves.builtins.open') def test_main(self, mock_file, mock_load, @@ -88,7 +88,6 @@ class TestProcessmonitorManager(testtools.TestCase): mock_restart_processes, mock_sleep): - mock_file.return_value = None mock_load.side_effect = [self._get_mock_process_list(0), self._get_mock_process_list(0), self._get_mock_process_list(1)] @@ -111,7 +110,7 @@ class TestProcessmonitorManager(testtools.TestCase): @mock.patch.object(handle_process.HandleProcess, 'start_processes') @mock.patch.object(handle_process.HandleProcess, 'set_process_list') @mock.patch.object(yaml, 'load') - @mock.patch('__builtin__.file') + @mock.patch('six.moves.builtins.open') def test_main_exception(self, mock_file, mock_load, @@ -120,7 +119,6 @@ class TestProcessmonitorManager(testtools.TestCase): mock_monitor_processes, mock_restart_processes): - mock_file.return_value = None mock_load.return_value = self._get_mock_process_list(0) mock_set_process_list.return_value = None mock_start_processes.side_effect = Exception("Test exception.") @@ -135,13 +133,12 @@ class TestProcessmonitorManager(testtools.TestCase): @mock.patch.object(handle_process.HandleProcess, 'set_process_list') @mock.patch.object(yaml, 'load') - @mock.patch('__builtin__.file') + @mock.patch('six.moves.builtins.open') def test_load_process_list_yaml_error(self, mock_file, mock_load, mock_set_process_list): - mock_file.return_value = None mock_load.side_effect = yaml.YAMLError obj = processmonitor_manager.ProcessmonitorManager() @@ -151,13 +148,12 @@ class TestProcessmonitorManager(testtools.TestCase): @mock.patch.object(handle_process.HandleProcess, 'set_process_list') @mock.patch.object(yaml, 'load') - @mock.patch('__builtin__.file') + @mock.patch('six.moves.builtins.open') def test_load_process_list_exception(self, mock_file, mock_load, mock_set_process_list): - mock_file.return_value = None mock_load.side_effect = Exception("Test exception.") obj = processmonitor_manager.ProcessmonitorManager() diff --git a/requirements.txt b/requirements.txt index 21fcfc9..1ee11e8 100644 --- a/requirements.txt +++ b/requirements.txt @@ -14,3 +14,4 @@ oslo.utils>=3.11.0 # Apache-2.0 pbr>=1.8 # Apache-2.0 python-masakariclient>=2.0.1.dev5 # Apache-2.0 python-openstackclient>=3.3.0 # Apache-2.0 +six>=1.9.0 # MIT diff --git a/setup.cfg b/setup.cfg index eebc66b..188d472 100644 --- a/setup.cfg +++ b/setup.cfg @@ -16,8 +16,7 @@ classifier = Programming Language :: Python :: 2 Programming Language :: Python :: 2.7 Programming Language :: Python :: 3 - Programming Language :: Python :: 3.3 - Programming Language :: Python :: 3.4 + Programming Language :: Python :: 3.5 [files] packages = diff --git a/test-requirements.txt b/test-requirements.txt index f9c0126..3dd2971 100644 --- a/test-requirements.txt +++ b/test-requirements.txt @@ -9,6 +9,7 @@ python-subunit>=0.0.18 # Apache-2.0/BSD sphinx>=1.2.1,!=1.3b1,<1.4 # BSD oslosphinx>=4.7.0 # Apache-2.0 oslotest>=1.10.0 # Apache-2.0 +os-testr>=0.8.0 # Apache-2.0 testrepository>=0.0.18 # Apache-2.0/BSD testscenarios>=0.4 # Apache-2.0/BSD testtools>=1.4.0 # MIT diff --git a/tox.ini b/tox.ini index f52d5c6..8a35bd0 100644 --- a/tox.ini +++ b/tox.ini @@ -1,16 +1,38 @@ [tox] minversion = 2.0 -envlist = py34,py27,pypy,pep8 +envlist = py35,py27,pypy,pep8 skipsdist = True [testenv] usedevelop = True install_command = pip install -c{env:UPPER_CONSTRAINTS_FILE:https://git.openstack.org/cgit/openstack/requirements/plain/upper-constraints.txt} {opts} {packages} -setenv = - VIRTUAL_ENV={envdir} - PYTHONWARNINGS=default::DeprecationWarning +setenv = VIRTUAL_ENV={envdir} + OS_TEST_PATH=./masakarimonitors/tests/unit + LANGUAGE=en_US + LC_ALL=en_US.utf-8 deps = -r{toxinidir}/test-requirements.txt -commands = python setup.py test --slowest --testr-args='{posargs}' +whitelist_externals = bash + find + rm + env +# By default ostestr will set concurrency +# to ncpu, to specify something else use +# the concurrency= option. +# call ie: 'tox -epy27 -- --concurrency=4' +commands = + find . -type f -name "*.pyc" -delete + rm -Rf .testrepository/times.dbm +passenv = http_proxy HTTP_PROXY https_proxy HTTPS_PROXY no_proxy NO_PROXY OS_DEBUG GENERATE_HASHES + +[testenv:py27] +commands = + {[testenv]commands} + ostestr '{posargs}' + +[testenv:py35] +commands = + {[testenv]commands} + ostestr '{posargs}' [testenv:genconfig] commands = oslo-config-generator --config-file=etc/masakarimonitors/masakarimonitors-config-generator.conf