Skip to content

Commit 4c3ba9f

Browse files
committed
test: "CCYYMMDD" is not a valid XSD date
XSD-date cannot be written in the form "CCYYMMDD", this patch adds a test to ensure it. linkml-runtime has been relying on Python `fromisoformat` [1] format to parse and, implicitly validate, XSD-date. But from Python 3.11 upwards `fromisoformat` also accepts "CCYYMMDD" as a valid date, breaking XSD-date compatibility. This is a regression test to avoid this issue in the future. [1]: https://docs.python.org/3/library/datetime.html#datetime.date.fromisoformat Signed-off-by: Silvano Cirujano Cuesta <silvano.cirujano-cuesta@siemens.com>
1 parent a20d420 commit 4c3ba9f

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

tests/test_utils/test_metamodelcore.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,8 @@ def test_date(self):
162162
self.assertEqual('2019-07-06', v.isoformat()) # A string
163163
self.assertEqual('2019-07-06', XSDDate(XSDDate(v))) # An existing date
164164
strict()
165+
with self.assertRaises(ValueError):
166+
XSDDate('20190706')
165167
with self.assertRaises(ValueError):
166168
XSDDate('Jan 12, 2019')
167169
with self.assertRaises(ValueError):

0 commit comments

Comments
 (0)