]> git.ipfire.org Git - thirdparty/psycopg.git/commitdiff
test: verify that time objects with failing utcoffset() are handled correctly
authorDaniele Varrazzo <daniele.varrazzo@gmail.com>
Tue, 3 Oct 2023 16:09:11 +0000 (18:09 +0200)
committerDaniele Varrazzo <daniele.varrazzo@gmail.com>
Tue, 3 Oct 2023 16:32:31 +0000 (18:32 +0200)
tests/types/test_datetime.py

index a64a62e13fc0a5c46cda154b69302fd2c12a643e..b582a96d90fd0a0804063d765c3202eab5b5fdb6 100644 (file)
@@ -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",
         [