Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit a899319

Browse files
committed
Make dbname optional in psql commands
1 parent 18691ce commit a899319

File tree

2 files changed

+5
-7
lines changed

2 files changed

+5
-7
lines changed

testgres/testgres.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -853,7 +853,7 @@ def cleanup(self, max_attempts=3):
853853

854854
return self
855855

856-
def psql(self, dbname, query=None, filename=None, username=None):
856+
def psql(self, query, filename=None, username=None, dbname='postgres'):
857857
"""
858858
Execute a query using psql.
859859
@@ -896,7 +896,7 @@ def psql(self, dbname, query=None, filename=None, username=None):
896896
out, err = process.communicate()
897897
return process.returncode, out, err
898898

899-
def safe_psql(self, dbname, query, username=None):
899+
def safe_psql(self, query, username=None, dbname='postgres'):
900900
"""
901901
Execute a query using psql.
902902
@@ -909,7 +909,7 @@ def safe_psql(self, dbname, query, username=None):
909909
psql's output as str.
910910
"""
911911

912-
ret, out, err = self.psql(dbname, query, username=username)
912+
ret, out, err = self.psql(query, username=username, dbname=dbname)
913913
if ret:
914914
err = '' if not err else err.decode('utf-8')
915915
raise QueryException(err)

tests/test_simple.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
# coding: utf-8
33

44
import os
5-
import re
65
import six
76
import subprocess
87
import tempfile
@@ -180,12 +179,12 @@ def test_backup_exhaust(self):
180179
with node.backup(xlog_method='fetch') as backup:
181180

182181
# exhaust backup by creating new node
183-
with backup.spawn_primary('node1') as node1:
182+
with backup.spawn_primary('node1'):
184183
pass
185184

186185
# now let's try to create one more node
187186
with self.assertRaises(BackupException):
188-
with backup.spawn_primary('node2') as node2:
187+
with backup.spawn_primary('node2'):
189188
pass
190189

191190
def test_users(self):
@@ -253,7 +252,6 @@ def test_version_management(self):
253252

254253
def test_configure(self):
255254
# set global if it wasn't set
256-
pg_config = get_pg_config()
257255
configure_testgres(cache_initdb=True, cache_pg_config=True)
258256

259257
# check that is the same instance

0 commit comments

Comments
 (0)