"tests/scripts",
"tests/test_conninfo.py",
"tests/test_dns*",
+ "tests/test_errors.py",
"tests/test_prepared*.py",
"tests/test_psycopg_dbapi20.py",
"tests/test_sql.py",
import pickle
+from typing import List
from weakref import ref
import pytest
res = pgconn.make_empty_result(pq.ExecStatus.NONFATAL_ERROR)
diag = e.Diagnostic(res)
- checked = []
+ to_check: pq.DiagnosticField
+ checked: List[pq.DiagnosticField] = []
def check_val(self, v):
nonlocal to_check
cur.execute("insert into test_exc values(2)")
diag = exc.value.diag
assert diag.sqlstate == "23514"
- assert diag.schema_name[:7] == "pg_temp"
+ assert diag.schema_name and diag.schema_name[:7] == "pg_temp"
assert diag.table_name == "test_exc"
assert diag.constraint_name == "chk_eq1"
if conn.pgconn.server_version >= 90600:
)
diag = excinfo.value.diag
- assert f'"{eur}"' in diag.message_primary
+ assert diag.message_primary and f'"{eur}"' in diag.message_primary
assert diag.sqlstate == "42P01"
s = str(exc.value)
assert "from wat" in s, s
+ assert exc.value.diag.message_primary
assert exc.value.diag.message_primary in s
assert "ERROR" not in s
assert not s.endswith("\n")