summaryrefslogtreecommitdiffstats
path: root/tests/utils.py
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2022-09-20 15:46:57 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2022-09-20 15:46:57 +0000
commit917739023a7acaae3645bbfd27ed454df3c5be33 (patch)
tree4e205849ae64ccd4d1797a1ad7579416f69f52ee /tests/utils.py
parentAdding upstream version 3.4.1. (diff)
downloadpgcli-917739023a7acaae3645bbfd27ed454df3c5be33.tar.xz
pgcli-917739023a7acaae3645bbfd27ed454df3c5be33.zip
Adding upstream version 3.5.0.upstream/3.5.0
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tests/utils.py')
-rw-r--r--tests/utils.py17
1 files changed, 7 insertions, 10 deletions
diff --git a/tests/utils.py b/tests/utils.py
index 460ea46..67d769f 100644
--- a/tests/utils.py
+++ b/tests/utils.py
@@ -1,8 +1,6 @@
import pytest
-import psycopg2
-import psycopg2.extras
+import psycopg
from pgcli.main import format_output, OutputSettings
-from pgcli.pgexecute import register_json_typecasters
from os import getenv
POSTGRES_USER = getenv("PGUSER", "postgres")
@@ -12,12 +10,12 @@ POSTGRES_PASSWORD = getenv("PGPASSWORD", "postgres")
def db_connection(dbname=None):
- conn = psycopg2.connect(
+ conn = psycopg.connect(
user=POSTGRES_USER,
host=POSTGRES_HOST,
password=POSTGRES_PASSWORD,
port=POSTGRES_PORT,
- database=dbname,
+ dbname=dbname,
)
conn.autocommit = True
return conn
@@ -26,11 +24,10 @@ def db_connection(dbname=None):
try:
conn = db_connection()
CAN_CONNECT_TO_DB = True
- SERVER_VERSION = conn.server_version
- json_types = register_json_typecasters(conn, lambda x: x)
- JSON_AVAILABLE = "json" in json_types
- JSONB_AVAILABLE = "jsonb" in json_types
-except:
+ SERVER_VERSION = conn.info.parameter_status("server_version")
+ JSON_AVAILABLE = True
+ JSONB_AVAILABLE = True
+except Exception as x:
CAN_CONNECT_TO_DB = JSON_AVAILABLE = JSONB_AVAILABLE = False
SERVER_VERSION = 0