diff --git a/test/dbapi/conftest.py b/test/dbapi/conftest.py index 9e97cf9..0d23126 100644 --- a/test/dbapi/conftest.py +++ b/test/dbapi/conftest.py @@ -1,7 +1,8 @@ from os import environ import pytest -import re + +from test.utils import parse_server_version import pg8000.dbapi @@ -58,5 +59,5 @@ def pg_version(cursor): cursor.execute("select current_setting('server_version')") retval = cursor.fetchall() version = retval[0][0] - major = re.match(r'\d+', version).group() # leading digits in 17.0, 17rc1 + major = parse_server_version(version) return int(major) diff --git a/test/native/conftest.py b/test/native/conftest.py index 32843ea..5088186 100644 --- a/test/native/conftest.py +++ b/test/native/conftest.py @@ -1,7 +1,8 @@ from os import environ import pytest -import re + +from test.utils import parse_server_version import pg8000.native @@ -46,5 +47,5 @@ def fin(): def pg_version(con): retval = con.run("select current_setting('server_version')") version = retval[0][0] - major = re.match(r'\d+', version).group() # leading digits in 17.0, 17rc1 + major = parse_server_version(version) return int(major) diff --git a/test/test_utils.py b/test/test_utils.py new file mode 100644 index 0000000..254c564 --- /dev/null +++ b/test/test_utils.py @@ -0,0 +1,5 @@ +from test.utils import parse_server_version + + +def test_parse_server_version(): + assert parse_server_version("17rc1") == 17 diff --git a/test/utils.py b/test/utils.py new file mode 100644 index 0000000..7e60778 --- /dev/null +++ b/test/utils.py @@ -0,0 +1,6 @@ +import re + + +def parse_server_version(version): + major = re.match(r"\d+", version).group() # leading digits in 17.0, 17rc1 + return int(major)