Python34 compatibility (#933)

and some other minor fixes.

Closes https://github.com/zalando/patroni/issues/932
This commit is contained in:
Alexander Kukushkin
2019-01-16 14:40:05 +01:00
committed by GitHub
parent 381a5b80d2
commit 2c128520cf
4 changed files with 16 additions and 15 deletions
+1 -1
View File
@@ -11,6 +11,6 @@ click>=4.1
prettytable>=0.7
tzlocal
python-dateutil
psutil
psutil>=2.0.0
cdiff
kubernetes>=2.0.0,<=7.0.0,!=4.0.*,!=5.0.*
+4 -1
View File
@@ -403,4 +403,7 @@ class TestRestApiServer(unittest.TestCase):
srv.reload_config({'listen': '127.0.0.2:8008'})
def test_handle_error(self):
self.assertIsNone(MockRestApiServer.handle_error(None, ('127.0.0.1', 55555)))
try:
raise Exception()
except Exception:
self.assertIsNone(MockRestApiServer.handle_error(None, ('127.0.0.1', 55555)))
+10 -12
View File
@@ -11,8 +11,8 @@ from patroni.log import PatroniLogger
class TestPatroniLogger(unittest.TestCase):
@patch('logging.FileHandler._open', Mock())
def setUp(self):
self.config = {
def test_patroni_logger(self):
config = {
'log': {
'dir': 'foo',
'file_size': 4096,
@@ -24,15 +24,13 @@ class TestPatroniLogger(unittest.TestCase):
'restapi': {}, 'postgresql': {'data_dir': 'foo'}
}
sys.argv = ['patroni.py']
os.environ[Config.PATRONI_CONFIG_VARIABLE] = yaml.dump(self.config, default_flow_style=False)
self.logger = PatroniLogger()
config = Config()
self.logger.reload_config(config['log'])
os.environ[Config.PATRONI_CONFIG_VARIABLE] = yaml.dump(config, default_flow_style=False)
logger = PatroniLogger()
patroni_config = Config()
logger.reload_config(patroni_config['log'])
def test_rotating_handler(self):
self.assertEqual(self.logger.handler.maxBytes, self.config['log']['file_size'])
self.assertEqual(self.logger.handler.backupCount, self.config['log']['file_num'])
self.assertEqual(logger.handler.maxBytes, config['log']['file_size'])
self.assertEqual(logger.handler.backupCount, config['log']['file_num'])
def test_reload_config(self):
self.config['log'].pop('dir')
self.logger.reload_config(self.config['log'])
config['log'].pop('dir')
logger.reload_config(config['log'])
+1 -1
View File
@@ -48,7 +48,7 @@ class TestPostmasterProcess(unittest.TestCase):
mock_init.side_effect = psutil.NoSuchProcess(123)
self.assertEqual(PostmasterProcess.from_pid(123), None)
mock_init.side_effect = None
self.assertNotEquals(PostmasterProcess.from_pid(123), None)
self.assertNotEqual(PostmasterProcess.from_pid(123), None)
@patch('psutil.Process.__init__', Mock())
@patch('psutil.Process.send_signal')