Skip to content

Commit 4248f3c

Browse files
committed
test: cover ISO8601 date values accepted by Python 3.11 datetime module
Python 3.11 `datetime` module allows additional ISO8601 date, time and date-time formats that are not RFC3339 5.6 compliant. This change adds tests for invalid `date` values that are at the moment allowed by at least Python `jsonschema` library as valid `date` sttrings. Looks like `date-time` and `time` test cases already cover at least some values that are valid by ISO8601 but not by RFC3339 section 5.6. See: * https://docs.python.org/3/whatsnew/3.11.html#datetime * python/cpython@1303f8c927 * https://docs.python.org/3.11/library/datetime.html#datetime.date.fromisoformat * https://www.rfc-editor.org/rfc/rfc3339#section-5.6 PR sent to `jsonschema` library python-jsonschema/jsonschema#1076.
1 parent 19947ea commit 4248f3c

File tree

4 files changed

+80
-0
lines changed

4 files changed

+80
-0
lines changed

tests/draft-next/optional/format/date.json

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,26 @@
220220
"description": "invalid non-ASCII '৪' (a Bengali 4)",
221221
"data": "1963-06-1৪",
222222
"valid": false
223+
},
224+
{
225+
"description": "ISO8601 / non-RFC3339: YYYYMMDD without dashes (2023-03-28)",
226+
"data": "20230328",
227+
"valid": false
228+
},
229+
{
230+
"description": "ISO8601 / non-RFC3339: week number implicit day of week (2023-01-02)",
231+
"data": "2023-W01",
232+
"valid": false
233+
},
234+
{
235+
"description": "ISO8601 / non-RFC3339: week number with day of week (2023-03-28)",
236+
"data": "2023-W13-2",
237+
"valid": false
238+
},
239+
{
240+
"description": "ISO8601 / non-RFC3339: week number rollover to next year (2023-01-01)",
241+
"data": "2022W527",
242+
"valid": false
223243
}
224244
]
225245
}

tests/draft2019-09/optional/format/date.json

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,26 @@
220220
"description": "invalid non-ASCII '৪' (a Bengali 4)",
221221
"data": "1963-06-1৪",
222222
"valid": false
223+
},
224+
{
225+
"description": "ISO8601 / non-RFC3339: YYYYMMDD without dashes (2023-03-28)",
226+
"data": "20230328",
227+
"valid": false
228+
},
229+
{
230+
"description": "ISO8601 / non-RFC3339: week number implicit day of week (2023-01-02)",
231+
"data": "2023-W01",
232+
"valid": false
233+
},
234+
{
235+
"description": "ISO8601 / non-RFC3339: week number with day of week (2023-03-28)",
236+
"data": "2023-W13-2",
237+
"valid": false
238+
},
239+
{
240+
"description": "ISO8601 / non-RFC3339: week number rollover to next year (2023-01-01)",
241+
"data": "2022W527",
242+
"valid": false
223243
}
224244
]
225245
}

tests/draft2020-12/optional/format/date.json

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,26 @@
220220
"description": "invalid non-ASCII '৪' (a Bengali 4)",
221221
"data": "1963-06-1৪",
222222
"valid": false
223+
},
224+
{
225+
"description": "ISO8601 / non-RFC3339: YYYYMMDD without dashes (2023-03-28)",
226+
"data": "20230328",
227+
"valid": false
228+
},
229+
{
230+
"description": "ISO8601 / non-RFC3339: week number implicit day of week (2023-01-02)",
231+
"data": "2023-W01",
232+
"valid": false
233+
},
234+
{
235+
"description": "ISO8601 / non-RFC3339: week number with day of week (2023-03-28)",
236+
"data": "2023-W13-2",
237+
"valid": false
238+
},
239+
{
240+
"description": "ISO8601 / non-RFC3339: week number rollover to next year (2023-01-01)",
241+
"data": "2022W527",
242+
"valid": false
223243
}
224244
]
225245
}

tests/draft7/optional/format/date.json

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,26 @@
217217
"description": "invalid non-ASCII '৪' (a Bengali 4)",
218218
"data": "1963-06-1৪",
219219
"valid": false
220+
},
221+
{
222+
"description": "ISO8601 / non-RFC3339: YYYYMMDD without dashes (2023-03-28)",
223+
"data": "20230328",
224+
"valid": false
225+
},
226+
{
227+
"description": "ISO8601 / non-RFC3339: week number implicit day of week (2023-01-02)",
228+
"data": "2023-W01",
229+
"valid": false
230+
},
231+
{
232+
"description": "ISO8601 / non-RFC3339: week number with day of week (2023-03-28)",
233+
"data": "2023-W13-2",
234+
"valid": false
235+
},
236+
{
237+
"description": "ISO8601 / non-RFC3339: week number rollover to next year (2023-01-01)",
238+
"data": "2022W527",
239+
"valid": false
220240
}
221241
]
222242
}

0 commit comments

Comments
 (0)