From: Denis Laxalde Date: Fri, 5 Nov 2021 08:27:45 +0000 (+0100) Subject: Check that tzinfo.utcoffset() does not return None in conninfo tests X-Git-Tag: 3.0.3~3^2~22 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e9e0ac7d63f90bd44c9cbdafed0b7952e7cd3379;p=thirdparty%2Fpsycopg.git Check that tzinfo.utcoffset() does not return None in conninfo tests Avoids mypy error: error: Item "None" of "Optional[timedelta]" has no attribute "total_seconds" [union-attr] Now test_conninfo.py type checks. --- diff --git a/pyproject.toml b/pyproject.toml index 3872d5162..42c7e27f4 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -23,6 +23,7 @@ files = [ "tests/pool", "tests/pq", "tests/scripts", + "tests/test_conninfo.py", "tests/test_dns*", "tests/test_psycopg_dbapi20.py", "tests/test_sql.py", diff --git a/tests/test_conninfo.py b/tests/test_conninfo.py index c210a3b37..4d098d24d 100644 --- a/tests/test_conninfo.py +++ b/tests/test_conninfo.py @@ -227,8 +227,10 @@ class TestConnectionInfo: conn.execute("set timezone to 'Europe/Rome'") tz = conn.info.timezone assert isinstance(tz, dt.tzinfo) - assert tz.utcoffset(dt.datetime(2000, 1, 1)).total_seconds() == 3600 - assert tz.utcoffset(dt.datetime(2000, 7, 1)).total_seconds() == 7200 + offset = tz.utcoffset(dt.datetime(2000, 1, 1)) + assert offset and offset.total_seconds() == 3600 + offset = tz.utcoffset(dt.datetime(2000, 7, 1)) + assert offset and offset.total_seconds() == 7200 def test_timezone_warn(self, conn, caplog): conn.execute("set timezone to 'FOOBAR0'")