summaryrefslogtreecommitdiffstats
path: root/tests/utils.py
diff options
context:
space:
mode:
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