potiuk commented on code in PR #27264:
URL: https://github.com/apache/airflow/pull/27264#discussion_r1200148599


##########
tests/models/test_param.py:
##########
@@ -123,23 +123,35 @@ def test_string_time_format(self):
         with pytest.raises(ParamValidationError, match=error_pattern):
             Param("24:00:00", type="string", format="time").resolve()
 
-    def test_string_date_format(self):
+    @pytest.mark.parametrize(
+        "date_string",
+        [
+            "2021-01-01",
+            pytest.param(
+                "20120503",
+                marks=pytest.mark.skipif(not PY311, reason="Improved 
fromisoformat() in 3.11."),
+            ),
+        ],
+    )
+    def test_string_date_format(self, date_string):
         """Test string date format."""
-        assert Param("2021-01-01", type="string", format="date").resolve() == 
"2021-01-01"
-
-        error_pattern = "is not a 'date'"
-        with pytest.raises(ParamValidationError, match=error_pattern):
-            Param("01/01/2021", type="string", format="date").resolve()
+        assert Param(date_string, type="string", format="date").resolve() == 
date_string
 
-        if PY311:
-            # in Python 3.11 `fromisoformat` will not raise an error for this 
one
-            Param("20120503", type="string", format="date").resolve()
-        else:
-            with pytest.raises(ParamValidationError, match=error_pattern):
-                Param("20120503", type="string", format="date").resolve()
-
-        with pytest.raises(ParamValidationError, match=error_pattern):
-            Param("21 May 1975", type="string", format="date").resolve()
+    @pytest.mark.parametrize(

Review Comment:
   NIce



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to