@@ -563,6 +563,42 @@ class TestConnectParams(tb.TestCase):
563563 })
564564 },
565565
566+ {
567+ 'name' : 'target_session_attrs' ,
568+ 'dsn' : 'postgresql://user@host1:1111,host2:2222/db'
569+ '?target_session_attrs=read-only' ,
570+ 'result' : ([('host1' , 1111 ), ('host2' , 2222 )], {
571+ 'database' : 'db' ,
572+ 'user' : 'user' ,
573+ 'target_session_attrs' : 'read-only' ,
574+ })
575+ },
576+
577+ {
578+ 'name' : 'target_session_attrs_2' ,
579+ 'dsn' : 'postgresql://user@host1:1111,host2:2222/db'
580+ '?target_session_attrs=read-only' ,
581+ 'target_session_attrs' : 'read-write' ,
582+ 'result' : ([('host1' , 1111 ), ('host2' , 2222 )], {
583+ 'database' : 'db' ,
584+ 'user' : 'user' ,
585+ 'target_session_attrs' : 'read-write' ,
586+ })
587+ },
588+
589+ {
590+ 'name' : 'target_session_attrs_3' ,
591+ 'dsn' : 'postgresql://user@host1:1111,host2:2222/db' ,
592+ 'env' : {
593+ 'PGTARGETSESSIONATTRS' : 'read-only' ,
594+ },
595+ 'result' : ([('host1' , 1111 ), ('host2' , 2222 )], {
596+ 'database' : 'db' ,
597+ 'user' : 'user' ,
598+ 'target_session_attrs' : 'read-only' ,
599+ })
600+ },
601+
566602 {
567603 'name' : 'dsn_ipv6_multi_host' ,
568604 'dsn' : 'postgresql://user@[2001:db8::1234%25eth0],[::1]/db' ,
0 commit comments