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

Commit 7fc973e

Browse files
committed
Porting testgres to python3
1 parent 653a0cf commit 7fc973e

File tree

3 files changed

+10
-10
lines changed

3 files changed

+10
-10
lines changed

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,5 @@
1010
#download_url = 'https://github.com/postgrespro/testgres/tarball/0.1.1',
1111
keywords = ['testing', 'postgresql'],
1212
classifiers = [],
13-
install_requires = ["pg8000"]
13+
install_requires = ["pg8000", "six"]
1414
)

testgres/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
from testgres import PostgresNode, get_new_node, clean_all, stop_all
1+
from .testgres import PostgresNode, get_new_node, clean_all, stop_all

testgres/testgres.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
import tempfile
3030
import shutil
3131
import time
32+
import six
3233

3334
# Try to use psycopg2 by default. If psycopg2 isn"t available then use
3435
# pg8000 which is slower but much more portable because uses only
@@ -120,7 +121,7 @@ def close(self):
120121
self.connection.close()
121122

122123

123-
class PostgresNode:
124+
class PostgresNode(object):
124125
def __init__(self, name, port):
125126
self.name = name
126127
self.host = '127.0.0.1'
@@ -258,7 +259,7 @@ def pg_ctl(self, command, params):
258259
pg_ctl = self.get_bin_path("pg_ctl")
259260

260261
arguments = [pg_ctl]
261-
for key, value in params.iteritems():
262+
for key, value in six.iteritems(params):
262263
arguments.append(key)
263264
if value:
264265
arguments.append(value)
@@ -363,9 +364,8 @@ def poll_query_until(self, dbname, query):
363364

364365
while attemps < max_attemps:
365366
ret = self.safe_psql(dbname, query)
366-
367367
# TODO: fix psql so that it returns result without newline
368-
if ret == "t\n":
368+
if ret == six.b("t\n"):
369369
return
370370

371371
time.sleep(1)
@@ -410,10 +410,10 @@ def get_config():
410410
pg_config_cmd = os.environ.get("PG_CONFIG") \
411411
if "PG_CONFIG" in os.environ else "pg_config"
412412

413-
out = subprocess.check_output([pg_config_cmd])
414-
for line in out.split("\n"):
415-
if line:
416-
key, value = unicode(line).split("=", 1)
413+
out = six.StringIO(subprocess.check_output([pg_config_cmd], universal_newlines=True))
414+
for line in out:
415+
if line and "=" in line:
416+
key, value = line.split("=", 1)
417417
pg_config_data[key.strip()] = value.strip()
418418

419419
# Numeric version format

0 commit comments

Comments
 (0)