From ceace0364689f8ac3ca7934eabff466378b92675 Mon Sep 17 00:00:00 2001 From: Alexander Kukushkin Date: Wed, 25 May 2016 14:49:33 +0200 Subject: [PATCH] Address codacy and travis issues --- features/environment.py | 4 ++-- patroni/postgresql.py | 3 ++- tests/test_config.py | 2 +- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/features/environment.py b/features/environment.py index bd03df46..16c6a3fe 100644 --- a/features/environment.py +++ b/features/environment.py @@ -110,7 +110,7 @@ class PatroniController(AbstractController): patroni_config_path = os.path.join(self._output_dir, patroni_config_name) with open(patroni_config_name) as f: - config = yaml.load(f) + config = yaml.safe_load(f) host = config['postgresql']['listen'].split(':')[0] @@ -143,7 +143,7 @@ class PatroniController(AbstractController): config['zookeeper'] = dcs_config with open(patroni_config_path, 'w') as f: - yaml.dump(config, f, default_flow_style=False) + yaml.safe_dump(config, f, default_flow_style=False) return patroni_config_path diff --git a/patroni/postgresql.py b/patroni/postgresql.py index 35aecae7..aeb229a1 100644 --- a/patroni/postgresql.py +++ b/patroni/postgresql.py @@ -120,7 +120,8 @@ class Postgresql(object): logger.exception('Failed to read PG_VERSION from %s', self._data_dir) return 0.0 - def get_server_parameters(self, config): + @staticmethod + def get_server_parameters(config): parameters = config['parameters'].copy() listen_addresses, port = (config['listen'] + ':5432').split(':')[:2] parameters.update({'listen_addresses': listen_addresses, 'port': port}) diff --git a/tests/test_config.py b/tests/test_config.py index 9c259796..ca2f2511 100644 --- a/tests/test_config.py +++ b/tests/test_config.py @@ -14,7 +14,7 @@ class TestConfig(unittest.TestCase): self.config = Config(config_env='postgresql: {data_dir: foo}') def test_reload_local_configuration(self): - Config(config_file='postgres0.yml').reload_local_configuration() + self.assertIsNone(Config(config_file='postgres0.yml').reload_local_configuration()) @patch('tempfile.mkstemp', Mock(return_value=[3000, 'blabla'])) @patch('os.path.exists', Mock(return_value=True))