Refs #23658 -- Fixed dbshell tests on Windows.

This commit is contained in:
Tim Graham 2015-07-06 16:17:56 -04:00
parent bc98bc56a5
commit 6bd8462380
1 changed files with 5 additions and 5 deletions

View File

@ -24,7 +24,7 @@ class PostgreSqlDbshellCommandTestCase(SimpleTestCase):
self.subprocess_args = list(*args) self.subprocess_args = list(*args)
if 'PGPASSFILE' in os.environ: if 'PGPASSFILE' in os.environ:
with open(os.environ['PGPASSFILE'], 'rb') as f: with open(os.environ['PGPASSFILE'], 'rb') as f:
self.pgpass = f.read() self.pgpass = f.read().strip() # ignore line endings
else: else:
self.pgpass = None self.pgpass = None
return 0 return 0
@ -44,7 +44,7 @@ class PostgreSqlDbshellCommandTestCase(SimpleTestCase):
'PORT': 444, 'PORT': 444,
}), ( }), (
['psql', '-U', 'someuser', '-h', 'somehost', '-p', '444', 'dbname'], ['psql', '-U', 'someuser', '-h', 'somehost', '-p', '444', 'dbname'],
b'somehost:444:dbname:someuser:somepassword\n', b'somehost:444:dbname:someuser:somepassword',
) )
) )
@ -71,7 +71,7 @@ class PostgreSqlDbshellCommandTestCase(SimpleTestCase):
'PORT': 444, 'PORT': 444,
}), ( }), (
['psql', '-U', 'some:user', '-h', '::1', '-p', '444', 'dbname'], ['psql', '-U', 'some:user', '-h', '::1', '-p', '444', 'dbname'],
b'\\:\\:1:444:dbname:some\\:user:some\\:password\n', b'\\:\\:1:444:dbname:some\\:user:some\\:password',
) )
) )
@ -85,7 +85,7 @@ class PostgreSqlDbshellCommandTestCase(SimpleTestCase):
'PORT': 444, 'PORT': 444,
}), ( }), (
['psql', '-U', 'some\\user', '-h', 'somehost', '-p', '444', 'dbname'], ['psql', '-U', 'some\\user', '-h', 'somehost', '-p', '444', 'dbname'],
b'somehost:444:dbname:some\\\\user:some\\\\password\n', b'somehost:444:dbname:some\\\\user:some\\\\password',
) )
) )
@ -98,7 +98,7 @@ class PostgreSqlDbshellCommandTestCase(SimpleTestCase):
username_str = force_str(username, encoding) username_str = force_str(username, encoding)
password_str = force_str(password, encoding) password_str = force_str(password, encoding)
pgpass_bytes = force_bytes( pgpass_bytes = force_bytes(
'somehost:444:dbname:%s:%s\n' % (username, password), 'somehost:444:dbname:%s:%s' % (username, password),
encoding=encoding, encoding=encoding,
) )
except UnicodeEncodeError: except UnicodeEncodeError: