]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
Further refine fractional seconds datetimeoffset fixture
authorMike Bayer <mike_mp@zzzcomputing.com>
Mon, 17 Feb 2020 14:41:59 +0000 (09:41 -0500)
committerMike Bayer <mike_mp@zzzcomputing.com>
Mon, 17 Feb 2020 14:43:18 +0000 (09:43 -0500)
in 55f6d61e85b7f16df0b77f1c55a4fb051cd696e3 we still
forgot to accommodate for Python 3 timezone constructor
rejecting fractional minutes so the test further needs lambdas
to prevent the constructor from invoking for Python versions
less than 3.7

Change-Id: I02a83888f5ffbbe53ed0ce16c46a70942add4a3c
(cherry picked from commit a8b4ea8819e08c0eaa74b53385a91c22916401c7)

test/dialect/mssql/test_types.py

index 1f0ae0a6fada752df281e0c4d35258aa091cfeca..92d3d9e3274e16bcffc41ac1854c9869d016e116 100644 (file)
@@ -749,10 +749,10 @@ class TypeRoundTripTest(
         return t
 
     @testing.combinations(
-        ("dto_param_none", None, None, False),
+        ("dto_param_none", lambda: None, None, False),
         (
             "dto_param_datetime_aware_positive",
-            datetime.datetime(
+            lambda: datetime.datetime(
                 2007,
                 10,
                 30,
@@ -767,7 +767,7 @@ class TypeRoundTripTest(
         ),
         (
             "dto_param_datetime_aware_negative",
-            datetime.datetime(
+            lambda: datetime.datetime(
                 2007,
                 10,
                 30,
@@ -782,7 +782,7 @@ class TypeRoundTripTest(
         ),
         (
             "dto_param_datetime_aware_seconds_frac_fail",
-            datetime.datetime(
+            lambda: datetime.datetime(
                 2007,
                 10,
                 30,
@@ -798,19 +798,24 @@ class TypeRoundTripTest(
         ),
         (
             "dto_param_datetime_naive",
-            datetime.datetime(2007, 10, 30, 11, 2, 32, 123456),
+            lambda: datetime.datetime(2007, 10, 30, 11, 2, 32, 123456),
             0,
             False,
         ),
         (
             "dto_param_string_one",
-            "2007-10-30 11:02:32.123456 +01:00",
+            lambda: "2007-10-30 11:02:32.123456 +01:00",
             1,
             False,
         ),
         # wow
-        ("dto_param_string_two", "October 30, 2007 11:02:32.123456", 0, False),
-        ("dto_param_string_invalid", "this is not a date", 0, True),
+        (
+            "dto_param_string_two",
+            lambda: "October 30, 2007 11:02:32.123456",
+            0,
+            False,
+        ),
+        ("dto_param_string_invalid", lambda: "this is not a date", 0, True),
         id_="iaaa",
         argnames="dto_param_value, expected_offset_hours, should_fail",
     )
@@ -822,6 +827,8 @@ class TypeRoundTripTest(
         should_fail,
     ):
         t = datetimeoffset_fixture
+        dto_param_value = dto_param_value()
+
         with testing.db.begin() as conn:
             if should_fail:
                 assert_raises(