Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/pendulum/parsing/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,10 @@ def _parse_iso8601_interval(text: str) -> _Interval:
raise ParserError("Invalid interval")

first, last = text.split("/")

if not first or not last:
raise ParserError("Invalid interval.")

start = end = duration = None

if first[0] == "P":
Expand Down
8 changes: 8 additions & 0 deletions tests/parsing/test_parsing_duration.py
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,14 @@ def test_parse_duration_invalid():
parse("P1Dasdfasdf")


def test_parse_interval_invalid():
with pytest.raises(ParserError):
parse("/no_start")

with pytest.raises(ParserError):
parse("no_end/")


def test_parse_duration_fraction_only_allowed_on_last_component():
with pytest.raises(ParserError):
parse("P2Y3M4DT5.5H6M7S")
Loading