From: Daniele Varrazzo Date: Thu, 9 May 2024 01:49:24 +0000 (+0200) Subject: test: adapt type representation tests to crdb and postgres < 15 X-Git-Tag: 3.2.0~29^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F811%2Fhead;p=thirdparty%2Fpsycopg.git test: adapt type representation tests to crdb and postgres < 15 --- diff --git a/tests/test_column.py b/tests/test_column.py index d5ae58fea..f23181027 100644 --- a/tests/test_column.py +++ b/tests/test_column.py @@ -3,7 +3,7 @@ import pickle import pytest from psycopg.postgres import types as builtins -from .fix_crdb import is_crdb, crdb_encoding +from .fix_crdb import is_crdb, crdb_encoding, skip_crdb def test_description_attribs(conn): @@ -62,6 +62,16 @@ def test_description_slice(conn): curs.description[0][0:2] == ("a", 23) +def skip_neg_scale(*args): + return pytest.param( + *args, + marks=[ + pytest.mark.crdb("skip", reason="negative precision numeric"), + pytest.mark.pg(">=15"), + ], + ) + + @pytest.mark.parametrize( "type, precision, scale, dsize, isize", [ @@ -71,15 +81,16 @@ def test_description_slice(conn): ("varchar(1)", None, None, 1, None), ("varchar(1)[]", None, None, 1, None), ("varchar(42)", None, None, 42, None), - ("bpchar(42)", None, None, 42, None), + skip_crdb("bpchar(42)", None, None, 42, None, reason="bpchar"), ("varchar(10485760)", None, None, 10485760, None), ("int4", None, None, None, 4), ("numeric", None, None, None, None), ("numeric(10,0)", 10, 0, None, None), ("numeric(10,3)[]", 10, 3, None, None), - ("numeric(10,-1)", 10, -1, None, None), - ("numeric(1,-1000)", 1, -1000, None, None), - ("numeric(1,1000)", 1, 1000, None, None), + skip_neg_scale("numeric(2,-3)", 2, -3, None, None), + skip_neg_scale("numeric(3,5)", 3, 5, None, None), + skip_neg_scale("numeric(1,-1000)", 1, -1000, None, None), + skip_neg_scale("numeric(1,1000)", 1, 1000, None, None), ("numeric(1000,1000)", 1000, 1000, None, None), ("time", None, None, None, 8), ("time[]", None, None, None, None), @@ -105,7 +116,8 @@ def test_details(conn, type, precision, scale, dsize, isize): assert col.precision == precision assert col.scale == scale assert col.display_size == dsize - assert col.internal_size == isize + if not is_crdb(conn): + assert col.internal_size == isize @pytest.mark.crdb("skip", reason="time precision")