Add one-sided ms timerange
This commit is contained in:
parent
c48876b196
commit
d8630ef847
@ -42,6 +42,8 @@ class TimeRange:
|
||||
(r'^-(\d{10})$', (None, 'date')),
|
||||
(r'^(\d{10})-$', ('date', None)),
|
||||
(r'^(\d{10})-(\d{10})$', ('date', 'date')),
|
||||
(r'^-(\d{13})$', (None, 'date')),
|
||||
(r'^(\d{13})-$', ('date', None)),
|
||||
(r'^(\d{13})-(\d{13})$', ('date', 'date')),
|
||||
]
|
||||
for rex, stype in syntax:
|
||||
|
@ -20,5 +20,11 @@ def test_parse_timerange_incorrect() -> None:
|
||||
timerange = TimeRange.parse_timerange('1231006505000-1233360000000')
|
||||
assert TimeRange('date', 'date', 1231006505, 1233360000) == timerange
|
||||
|
||||
timerange = TimeRange.parse_timerange('1231006505000-')
|
||||
assert TimeRange('date', None, 1231006505, 0) == timerange
|
||||
|
||||
timerange = TimeRange.parse_timerange('-1231006505000')
|
||||
assert TimeRange(None, 'date', 0, 1231006505) == timerange
|
||||
|
||||
with pytest.raises(Exception, match=r'Incorrect syntax.*'):
|
||||
TimeRange.parse_timerange('-')
|
||||
|
Loading…
Reference in New Issue
Block a user