From: Daniele Varrazzo Date: Thu, 8 Dec 2022 14:00:37 +0000 (+0000) Subject: test: add test to verify missing oid lookups in string formats X-Git-Tag: 3.1.5~13^2~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7fcf202ec04032325c1a3ef5bd6807584644ecc3;p=thirdparty%2Fpsycopg.git test: add test to verify missing oid lookups in string formats --- diff --git a/tests/types/test_numeric.py b/tests/types/test_numeric.py index cc471e8c7..a27bc849c 100644 --- a/tests/types/test_numeric.py +++ b/tests/types/test_numeric.py @@ -612,3 +612,14 @@ def test_repr_wrapper(conn, wrapper, fmt_in): cur = conn.execute(f"select pg_typeof(%{fmt_in.value})::oid", [wrapper(0)]) oid = cur.fetchone()[0] assert oid == psycopg.postgres.types[wrapper.__name__.lower()].oid + + +@pytest.mark.parametrize("fmt_out", pq.Format) +@pytest.mark.parametrize( + "typename", + "integer int2 int4 int8 float4 float8 numeric".split() + ["double precision"], +) +def test_oid_lookup(conn, typename, fmt_out): + dumper = conn.adapters.get_dumper_by_oid(conn.adapters.types[typename].oid, fmt_out) + assert dumper.oid == conn.adapters.types[typename].oid + assert dumper.format == fmt_out diff --git a/tests/types/test_string.py b/tests/types/test_string.py index 8499959e1..d23e5e03b 100644 --- a/tests/types/test_string.py +++ b/tests/types/test_string.py @@ -241,6 +241,14 @@ def test_text_array_ascii(conn, fmt_in, fmt_out): assert res == exp +@pytest.mark.parametrize("fmt_out", pq.Format) +@pytest.mark.parametrize("typename", ["text", "varchar", "name"]) +def test_oid_lookup(conn, typename, fmt_out): + dumper = conn.adapters.get_dumper_by_oid(conn.adapters.types[typename].oid, fmt_out) + assert dumper.oid == conn.adapters.types[typename].oid + assert dumper.format == fmt_out + + # # tests with bytea #