diff --git a/test/pgproto/tabcompletion_test.py b/test/pgproto/tab_completion_test.py similarity index 67% rename from test/pgproto/tabcompletion_test.py rename to test/pgproto/tab_completion_test.py index 97a13fea645290e9e60ed6d1f28723d48ea529d1..99185ebcb3120f476fad57f082a1c38dd2e8db61 100644 --- a/test/pgproto/tabcompletion_test.py +++ b/test/pgproto/tab_completion_test.py @@ -2,12 +2,27 @@ import shutil import sys import pexpect # type: ignore import pytest +import subprocess +import re from conftest import Postgres +from packaging.version import Version # type: ignore -def test_tabcompletion(postgres: Postgres): +def psql_version() -> Version: + cmd = ["psql", "--version"] + output = subprocess.check_output(cmd).decode("utf-8") + raw_version = re.sub(r"\([^)]*\)", "", output).strip() + version = raw_version.rpartition(" ")[-1] + return Version(version) + + +def test_tab_completion(postgres: Postgres): if not shutil.which("psql"): - pytest.skip("couldn't find psql") + pytest.skip("cannot find psql") + + version = psql_version() + if version < Version("15"): + pytest.skip(f"unsupported psql {version}") user = "postgres" password = "Passw0rd"