Skip to content

Commit 942b2df

Browse files
committed
fix auth_test
1 parent 3f650ed commit 942b2df

File tree

2 files changed

+10
-7
lines changed

2 files changed

+10
-7
lines changed

tests/auth_test.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,11 @@ def setUp(self):
8383
'-U', 'backup',
8484
'-b', 'FULL'
8585
]
86+
self.pgpass_file = os.path.join(os.path.expanduser('~'), '.pgpass')
87+
try:
88+
os.remove(self.pgpass_file)
89+
except FileNotFoundError:
90+
pass
8691

8792
def tearDown(self):
8893
pass
@@ -142,9 +147,8 @@ def test_pgpassfile_env(self):
142147
self.fail(e)
143148

144149
def test_pgpass(self):
145-
path = os.path.join(os.path.expanduser('~'), '.pgpass')
146150
line = ":".join(['127.0.0.1', str(self.node.port), 'postgres', 'backup', 'password'])
147-
create_pgpass(path, line)
151+
create_pgpass(self.pgpass_file, line)
148152
try:
149153
self.assertEqual(
150154
"OK",
@@ -155,9 +159,8 @@ def test_pgpass(self):
155159
self.fail(e)
156160

157161
def test_pgpassword(self):
158-
path = os.path.join(os.path.expanduser('~'), '.pgpass')
159162
line = ":".join(['127.0.0.1', str(self.node.port), 'postgres', 'backup', 'wrong_password'])
160-
create_pgpass(path, line)
163+
create_pgpass(self.pgpass_file, line)
161164
os.environ["PGPASSWORD"] = 'password'
162165
try:
163166
self.assertEqual(
@@ -201,7 +204,7 @@ def modify_pg_hba(node):
201204

202205

203206
def create_pgpass(path, line):
204-
with open(path, 'w+') as passfile:
207+
with open(path, 'w') as passfile:
205208
# host:port:db:username:password
206209
passfile.write(line)
207-
os.chmod(path, 0600)
210+
os.chmod(path, 0o600)

tests/ptrack.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
from .helpers.ptrack_helpers import ProbackupTest, ProbackupException
44
from datetime import datetime, timedelta
55
import subprocess
6-
from testgres import ClusterException
6+
from testgres import ClusterTestgresException as ClusterException
77
import shutil, sys, time
88

99

0 commit comments

Comments
 (0)