Skip to content

Commit 7a63ea3

Browse files
committed
#782: Use isoduration instead of isodate for duration format validation, remove duration format test skips
1 parent e19671c commit 7a63ea3

File tree

3 files changed

+5
-29
lines changed

3 files changed

+5
-29
lines changed

jsonschema/_format.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -462,15 +462,15 @@ def is_uri_template(
462462

463463

464464
try:
465-
import isodate
465+
import isoduration
466466
except ImportError:
467467
pass
468468
else:
469469
@_checks_drafts(
470470
draft202012="duration",
471-
raises=isodate.ISO8601Error,
471+
raises=isoduration.DurationParsingException,
472472
)
473473
def is_duration(instance):
474474
if not isinstance(instance, str):
475475
return True
476-
return isodate.parse_duration(instance)
476+
return isoduration.parse_duration(instance)

jsonschema/tests/test_jsonschema_test_suite.py

-24
Original file line numberDiff line numberDiff line change
@@ -172,29 +172,6 @@ def format_validation_annotation(test):
172172
)(test)
173173

174174

175-
def duration_format_validation(test):
176-
"""
177-
isodata.parse_duration allows some formats that should not be parsed
178-
"""
179-
return skip(
180-
message=bug(),
181-
subject="duration",
182-
description='no time elements present', # P1YT
183-
)(test) or skip(
184-
message=bug(),
185-
subject="duration",
186-
description='weeks cannot be combined with other units', # P1Y2W
187-
)(test) or skip(
188-
message=bug(),
189-
subject="duration",
190-
description='zero time, in days', # P0D
191-
)(test) or skip(
192-
message=bug(),
193-
subject="duration",
194-
description='zero time, in seconds', # PT0S
195-
)(test)
196-
197-
198175
def ecmascript_regex_validation(test):
199176
"""
200177
Considering switching from re to js-regex after the following issues are resolved:
@@ -642,7 +619,6 @@ def ecmascript_regex_validation(test):
642619
or leap_second(test)
643620
or missing_format(draft202012_format_checker)(test)
644621
or complex_email_validation(test)
645-
or duration_format_validation(test)
646622
or format_validation_annotation(test)
647623
or ecmascript_regex_validation(test)
648624
or skip(

setup.cfg

+2-2
Original file line numberDiff line numberDiff line change
@@ -38,15 +38,15 @@ format =
3838
rfc3987
3939
strict-rfc3339
4040
webcolors
41-
isodate
41+
isoduration
4242
format_nongpl =
4343
fqdn
4444
idna
4545
jsonpointer>1.13
4646
webcolors
4747
rfc3986-validator>0.1.0
4848
rfc3339-validator
49-
isodate
49+
isoduration
5050

5151
[options.entry_points]
5252
console_scripts =

0 commit comments

Comments
 (0)