From 7793887ea74b24724eb9b92d7f246048b63a074c Mon Sep 17 00:00:00 2001 From: Alexander Kukushkin Date: Wed, 27 Nov 2019 14:57:33 +0100 Subject: [PATCH] Fix tests on windows (#1303) and disable junit, it produces a deprecation warning --- setup.py | 2 +- tests/__init__.py | 2 +- tests/test_postgresql.py | 4 +++- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/setup.py b/setup.py index 027f5db0..005365de 100644 --- a/setup.py +++ b/setup.py @@ -34,7 +34,7 @@ KEYWORDS = 'etcd governor patroni postgresql postgres ha haproxy confd' +\ COVERAGE_XML = True COVERAGE_HTML = False -JUNIT_XML = True +JUNIT_XML = False # Add here all kinds of additional classifiers as defined under # https://pypi.python.org/pypi?%3Aaction=list_classifiers diff --git a/tests/__init__.py b/tests/__init__.py index 84d2b772..2781d0a4 100644 --- a/tests/__init__.py +++ b/tests/__init__.py @@ -172,7 +172,7 @@ class PostgresInit(unittest.TestCase): @patch.object(ConfigHandler, 'replace_pg_ident', Mock()) @patch.object(Postgresql, 'get_postgres_role_from_data_directory', Mock(return_value='master')) def setUp(self): - data_dir = 'data/test0' + data_dir = os.path.join('data', 'test0') self.p = Postgresql({'name': 'postgresql0', 'scope': 'batman', 'data_dir': data_dir, 'config_dir': data_dir, 'retry_timeout': 10, 'krbsrvname': 'postgres', 'pgpass': os.path.join(data_dir, 'pgpass0'), diff --git a/tests/test_postgresql.py b/tests/test_postgresql.py index b057e2f8..9e97f4e5 100644 --- a/tests/test_postgresql.py +++ b/tests/test_postgresql.py @@ -1,6 +1,7 @@ import mock # for the mock.call method, importing it without a namespace breaks python3 import os import psycopg2 +import re import subprocess import time @@ -220,7 +221,8 @@ class TestPostgresql(BaseTestPostgresql): with patch('patroni.postgresql.config.ConfigHandler.primary_conninfo_params', Mock(return_value=conninfo)): mock_get_pg_settings.return_value['recovery_min_apply_delay'][1] = '1' self.assertEqual(self.p.config.check_recovery_conf(None), (True, True)) - mock_get_pg_settings.return_value['primary_conninfo'][1] = 'host=1 passfile=' + self.p.config._pgpass + mock_get_pg_settings.return_value['primary_conninfo'][1] = 'host=1 passfile='\ + + re.sub(r'([\'\\ ])', r'\\\1', self.p.config._pgpass) mock_get_pg_settings.return_value['recovery_min_apply_delay'][1] = '0' self.assertEqual(self.p.config.check_recovery_conf(None), (True, True)) self.p.config.write_recovery_conf({'standby_mode': 'on', 'primary_conninfo': conninfo.copy()})