From: Daniele Varrazzo Date: Tue, 3 Oct 2023 16:09:11 +0000 (+0200) Subject: test: verify that time objects with failing utcoffset() are handled correctly X-Git-Tag: pool-3.1.9~11^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8e4d3b37d8b9524cb619aadc10faf8408cd48747;p=thirdparty%2Fpsycopg.git test: verify that time objects with failing utcoffset() are handled correctly --- diff --git a/tests/types/test_datetime.py b/tests/types/test_datetime.py index a64a62e13..b582a96d9 100644 --- a/tests/types/test_datetime.py +++ b/tests/types/test_datetime.py @@ -576,6 +576,22 @@ class TestTimeTz: with pytest.raises(DataError, match="Europe/Rome"): conn.execute(f"select %{fmt_in.value}", (t,)) + @pytest.mark.parametrize("fmt_in", PyFormat) + def test_dump_timetz_overflow(self, conn, fmt_in): + class MyTimeZone(dt.tzinfo): + def dst(self, dt_): + return None + + def utcoffset(self, dt_): + return dt.timedelta(hours=25) + + def tzname(self, dt_): + return "lol" + + t = dt.time(12, 0, tzinfo=MyTimeZone()) + with pytest.raises(ValueError): + conn.execute(f"select %{fmt_in.value}", (t,)) + @pytest.mark.parametrize( "val, expr, timezone", [