Skip to content

Commit cdc3d24

Browse files
s.logvinenkos.logvinenko
authored andcommitted
fix auth_test
1 parent 90e8c80 commit cdc3d24

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

tests/auth_test.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,13 @@ def setUp(self):
8383
'-U', 'backup',
8484
'-b', 'FULL'
8585
]
86-
os.unsetenv("PGPASSWORD")
87-
os.unsetenv("PGPASSFILE")
86+
87+
if "PGPASSWORD" in self.pb.test_env.keys():
88+
del self.pb.test_env["PGPASSWORD"]
89+
90+
if "PGPASSWORD" in self.pb.test_env.keys():
91+
del self.pb.test_env["PGPASSFILE"]
92+
8893
try:
8994
os.remove(self.pgpass_file)
9095
except OSError:
@@ -143,7 +148,7 @@ def test_pgpassfile_env(self):
143148
path = os.path.join(self.pb.tmp_path, module_name, 'pgpass.conf')
144149
line = ":".join(['127.0.0.1', str(self.node.port), 'postgres', 'backup', 'password'])
145150
create_pgpass(path, line)
146-
os.environ["PGPASSFILE"] = path
151+
self.pb.test_env["PGPASSFILE"] = path
147152
try:
148153
self.assertEqual(
149154
"OK",
@@ -168,7 +173,7 @@ def test_pgpass(self):
168173

169174
def test_pgpassword(self):
170175
""" Test case: PGPB_AUTH08 - set environment var PGPASSWORD """
171-
os.environ["PGPASSWORD"] = "password"
176+
self.pb.test_env["PGPASSWORD"] = "password"
172177
try:
173178
self.assertEqual(
174179
"OK",
@@ -182,7 +187,7 @@ def test_pgpassword_and_wrong_pgpass(self):
182187
""" Test case: PGPB_AUTH09 - Check priority between PGPASSWORD and .pgpass file"""
183188
line = ":".join(['127.0.0.1', str(self.node.port), 'postgres', 'backup', 'wrong_password'])
184189
create_pgpass(self.pgpass_file, line)
185-
os.environ["PGPASSWORD"] = "password"
190+
self.pb.test_env["PGPASSWORD"] = "password"
186191
try:
187192
self.assertEqual(
188193
"OK",

0 commit comments

Comments
 (0)