]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
Skip sub-minute timezone tests for Python 3 < 3.7
authorMike Bayer <mike_mp@zzzcomputing.com>
Mon, 2 Dec 2019 16:47:08 +0000 (11:47 -0500)
committerMike Bayer <mike_mp@zzzcomputing.com>
Mon, 2 Dec 2019 16:48:55 +0000 (11:48 -0500)
The datetime.timezone class as of Python 3.7, or SQLAlchemy's port for Python
2, supports seconds and microseconds.  For Python 3.6 and earlier, it is not
supported.

Fixes: #5016
Change-Id: Ia347d5a9958c0fa53317b2e340162e2009667bc2
(cherry picked from commit 380f4389922004589bfa7cb4f9b8c8208aa68659)

test/base/test_utils.py
test/requirements.py

index 7004239fe8e076aad068bc6f8222b9f09706f7cd..23436a6fd61510efaad15716cf7ba92f34974355 100644 (file)
@@ -2782,13 +2782,18 @@ class TimezoneTest(fixtures.TestBase):
         (datetime.timedelta(0), "UTC"),
         (datetime.timedelta(hours=5), "UTC+05:00"),
         (datetime.timedelta(hours=5, minutes=10), "UTC+05:10"),
-        (datetime.timedelta(hours=5, minutes=10, seconds=27), "UTC+05:10:27"),
+        (
+            datetime.timedelta(hours=5, minutes=10, seconds=27),
+            "UTC+05:10:27",
+            testing.requires.granular_timezone,
+        ),
         (datetime.timedelta(hours=-3, minutes=10), "UTC-02:50"),
         (
             datetime.timedelta(
                 hours=5, minutes=10, seconds=27, microseconds=550
             ),
             "UTC+05:10:27.000550",
+            testing.requires.granular_timezone,
         ),
     )
     def test_tzname(self, td, expected):
index c94fd0e0e2bc4e16aaaa648bb2a1d8dd4c303572..8f0cbc1b77575c7debef761a6c0f64225c2d3b6a 100644 (file)
@@ -1302,6 +1302,19 @@ class DefaultRequirements(SuiteRequirements):
             "Python issue 8743 fixed in Python 2.7.8",
         )
 
+    @property
+    def granular_timezone(self):
+        """the datetime.timezone class, or SQLAlchemy's port, supports
+        seconds and microseconds.
+
+        SQLAlchemy ported the Python 3.7 version for Python 2, so
+        it passes on that.  For Python 3.6 and earlier, it is not supported.
+
+        """
+        return exclusions.skip_if(
+            lambda: sys.version_info >= (3,) and sys.version_info < (3, 7)
+        )
+
     @property
     def selectone(self):
         """target driver must support the literal statement 'select 1'"""