From: Daniele Varrazzo Date: Wed, 9 Feb 2022 21:03:35 +0000 (+0100) Subject: Make the tzdata package a dependency on Windows X-Git-Tag: pool-3.1.1~7 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7a3772bba152028308dc8e2ae4f80afeede180a3;p=thirdparty%2Fpsycopg.git Make the tzdata package a dependency on Windows The package replaces the missing system tz database and allows to avoid the warning and return timestamps in the client timezone instead of in UTC. Close #223 --- diff --git a/docs/news.rst b/docs/news.rst index f6ae9468e..1e6cd9437 100644 --- a/docs/news.rst +++ b/docs/news.rst @@ -21,6 +21,13 @@ Psycopg 3.1 (unreleased) - Drop support for Python 3.6. +Psycopg 3.0.9 (unreleased) +^^^^^^^^^^^^^^^^^^^^^^^^^^ + +- Add the `!tzdata` package as a dependency on Windows in order to handle time + zones (:ticket:`#223`). + + Current release --------------- diff --git a/psycopg/setup.cfg b/psycopg/setup.cfg index f0d3b9f97..fac80d853 100644 --- a/psycopg/setup.cfg +++ b/psycopg/setup.cfg @@ -40,6 +40,7 @@ zip_safe = False install_requires = backports.zoneinfo >= 0.2.0; python_version < "3.9" typing_extensions >= 3.10; python_version < "3.8" + tzdata; sys_platform == "win32" [options.package_data] psycopg = py.typed diff --git a/tests/test_conninfo.py b/tests/test_conninfo.py index 63573d78b..65bc9fc4b 100644 --- a/tests/test_conninfo.py +++ b/tests/test_conninfo.py @@ -1,4 +1,3 @@ -import sys import datetime as dt import pytest @@ -218,7 +217,6 @@ class TestConnectionInfo: with pytest.raises(psycopg.OperationalError): conn.info.backend_pid - @pytest.mark.skipif(sys.platform == "win32", reason="no IANA db on Windows") def test_timezone(self, conn): conn.execute("set timezone to 'Europe/Rome'") tz = conn.info.timezone diff --git a/tests/types/test_datetime.py b/tests/types/test_datetime.py index 79ceeefb3..05416d743 100644 --- a/tests/types/test_datetime.py +++ b/tests/types/test_datetime.py @@ -1,4 +1,3 @@ -import sys import datetime as dt import pytest @@ -291,8 +290,6 @@ class TestDateTimeTz: ) @pytest.mark.parametrize("fmt_out", pq.Format) def test_load_datetimetz_tz(self, conn, fmt_out, tzname, expr, tzoff): - if "/" in tzname and sys.platform == "win32": - pytest.skip("no IANA db on Windows") conn.execute("select set_config('TimeZone', %s, true)", [tzname]) cur = conn.cursor(binary=fmt_out) ts = cur.execute("select %s::timestamptz", [expr]).fetchone()[0] @@ -337,7 +334,6 @@ class TestDateTimeTz: assert rec[0] == want assert rec[1] == 11111111 - @pytest.mark.xfail(sys.platform == "win32", reason="no IANA db on Windows") @pytest.mark.parametrize( "valname, tzval, tzname", [