File tree Expand file tree Collapse file tree 2 files changed +36
-2
lines changed Expand file tree Collapse file tree 2 files changed +36
-2
lines changed Original file line number Diff line number Diff line change @@ -179,9 +179,13 @@ def _parse_hostlist(hostlist, port):
179179 port = _validate_port_spec (hostspecs , port )
180180
181181 for i , hostspec in enumerate (hostspecs ):
182- addr , _ , hostspec_port = hostspec .partition (':' )
183- hosts .append (addr )
182+ if not hostspec .startswith ('/' ):
183+ addr , _ , hostspec_port = hostspec .partition (':' )
184+ else :
185+ addr = hostspec
186+ hostspec_port = ''
184187
188+ hosts .append (addr )
185189 if not port :
186190 if hostspec_port :
187191 hostlist_ports .append (int (hostspec_port ))
Original file line number Diff line number Diff line change @@ -475,6 +475,36 @@ class TestConnectParams(tb.TestCase):
475475 }
476476 )
477477 },
478+ {
479+ 'dsn' : 'postgres:///db?host=/cloudsql/'
480+ 'project:region:instance-name&user=spam' ,
481+ 'result' : (
482+ [os .path .join (
483+ '/cloudsql/project:region:instance-name' ,
484+ '.s.PGSQL.5432'
485+ )], {
486+ 'user' : 'spam' ,
487+ 'database' : 'db'
488+ }
489+ )
490+ },
491+ {
492+ 'dsn' : 'postgres:///db?host=127.0.0.1:5432,/cloudsql/'
493+ 'project:region:instance-name,localhost:5433&user=spam' ,
494+ 'result' : (
495+ [
496+ ('127.0.0.1' , 5432 ),
497+ os .path .join (
498+ '/cloudsql/project:region:instance-name' ,
499+ '.s.PGSQL.5432'
500+ ),
501+ ('localhost' , 5433 )
502+ ], {
503+ 'user' : 'spam' ,
504+ 'database' : 'db'
505+ }
506+ )
507+ },
478508 ]
479509
480510 @contextlib .contextmanager
You can’t perform that action at this time.
0 commit comments