From d7faaff57a7a9c0029a31f09564d30ab35007907 Mon Sep 17 00:00:00 2001 From: Marcel <62351477+lezram@users.noreply.github.com> Date: Wed, 11 Oct 2023 00:37:14 +0200 Subject: [PATCH] fix: allow host tuple (#1021) --- asyncpg/connect_utils.py | 2 +- tests/test_connect.py | 13 +++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/asyncpg/connect_utils.py b/asyncpg/connect_utils.py index 760e1297..414231fd 100644 --- a/asyncpg/connect_utils.py +++ b/asyncpg/connect_utils.py @@ -403,7 +403,7 @@ def _parse_connect_dsn_and_args(*, dsn, host, port, user, host = ['/run/postgresql', '/var/run/postgresql', '/tmp', '/private/tmp', 'localhost'] - if not isinstance(host, list): + if not isinstance(host, (list, tuple)): host = [host] if auth_hosts is None: diff --git a/tests/test_connect.py b/tests/test_connect.py index 1af074f1..5333e2c5 100644 --- a/tests/test_connect.py +++ b/tests/test_connect.py @@ -671,6 +671,19 @@ class TestConnectParams(tb.TestCase): 'target_session_attrs': 'any', }) }, + { + 'name': 'params_multi_host_dsn_env_mix_tuple', + 'env': { + 'PGUSER': 'foo', + }, + 'dsn': 'postgresql:///db', + 'host': ('host1', 'host2'), + 'result': ([('host1', 5432), ('host2', 5432)], { + 'database': 'db', + 'user': 'foo', + 'target_session_attrs': 'any', + }) + }, { 'name': 'params_combine_dsn_settings_override_and_ssl',