From cdc3d240af1b6446a14c9b8469c04333dacd8f1a Mon Sep 17 00:00:00 2001 From: "s.logvinenko" Date: Wed, 6 Dec 2017 16:26:30 +0300 Subject: [PATCH] fix auth_test --- tests/auth_test.py | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/tests/auth_test.py b/tests/auth_test.py index e9e44919..0a469c57 100644 --- a/tests/auth_test.py +++ b/tests/auth_test.py @@ -83,8 +83,13 @@ class AuthTest(unittest.TestCase): '-U', 'backup', '-b', 'FULL' ] - os.unsetenv("PGPASSWORD") - os.unsetenv("PGPASSFILE") + + if "PGPASSWORD" in self.pb.test_env.keys(): + del self.pb.test_env["PGPASSWORD"] + + if "PGPASSWORD" in self.pb.test_env.keys(): + del self.pb.test_env["PGPASSFILE"] + try: os.remove(self.pgpass_file) except OSError: @@ -143,7 +148,7 @@ class AuthTest(unittest.TestCase): path = os.path.join(self.pb.tmp_path, module_name, 'pgpass.conf') line = ":".join(['127.0.0.1', str(self.node.port), 'postgres', 'backup', 'password']) create_pgpass(path, line) - os.environ["PGPASSFILE"] = path + self.pb.test_env["PGPASSFILE"] = path try: self.assertEqual( "OK", @@ -168,7 +173,7 @@ class AuthTest(unittest.TestCase): def test_pgpassword(self): """ Test case: PGPB_AUTH08 - set environment var PGPASSWORD """ - os.environ["PGPASSWORD"] = "password" + self.pb.test_env["PGPASSWORD"] = "password" try: self.assertEqual( "OK", @@ -182,7 +187,7 @@ class AuthTest(unittest.TestCase): """ Test case: PGPB_AUTH09 - Check priority between PGPASSWORD and .pgpass file""" line = ":".join(['127.0.0.1', str(self.node.port), 'postgres', 'backup', 'wrong_password']) create_pgpass(self.pgpass_file, line) - os.environ["PGPASSWORD"] = "password" + self.pb.test_env["PGPASSWORD"] = "password" try: self.assertEqual( "OK",