mirror of
https://github.com/Tautulli/Tautulli.git
synced 2025-08-20 21:33:18 -07:00
Update datutil-2.8.2
This commit is contained in:
parent
439ca8ebb8
commit
3b645cf6c3
37 changed files with 16696 additions and 2664 deletions
27
lib/dateutil/test/property/test_isoparse_prop.py
Normal file
27
lib/dateutil/test/property/test_isoparse_prop.py
Normal file
|
@ -0,0 +1,27 @@
|
|||
from hypothesis import given, assume
|
||||
from hypothesis import strategies as st
|
||||
|
||||
from dateutil import tz
|
||||
from dateutil.parser import isoparse
|
||||
|
||||
import pytest
|
||||
|
||||
# Strategies
|
||||
TIME_ZONE_STRATEGY = st.sampled_from([None, tz.UTC] +
|
||||
[tz.gettz(zname) for zname in ('US/Eastern', 'US/Pacific',
|
||||
'Australia/Sydney', 'Europe/London')])
|
||||
ASCII_STRATEGY = st.characters(max_codepoint=127)
|
||||
|
||||
|
||||
@pytest.mark.isoparser
|
||||
@given(dt=st.datetimes(timezones=TIME_ZONE_STRATEGY), sep=ASCII_STRATEGY)
|
||||
def test_timespec_auto(dt, sep):
|
||||
if dt.tzinfo is not None:
|
||||
# Assume offset has no sub-second components
|
||||
assume(dt.utcoffset().total_seconds() % 60 == 0)
|
||||
|
||||
sep = str(sep) # Python 2.7 requires bytes
|
||||
dtstr = dt.isoformat(sep=sep)
|
||||
dt_rt = isoparse(dtstr)
|
||||
|
||||
assert dt_rt == dt
|
22
lib/dateutil/test/property/test_parser_prop.py
Normal file
22
lib/dateutil/test/property/test_parser_prop.py
Normal file
|
@ -0,0 +1,22 @@
|
|||
from hypothesis.strategies import integers
|
||||
from hypothesis import given
|
||||
|
||||
import pytest
|
||||
|
||||
from dateutil.parser import parserinfo
|
||||
|
||||
|
||||
@pytest.mark.parserinfo
|
||||
@given(integers(min_value=100, max_value=9999))
|
||||
def test_convertyear(n):
|
||||
assert n == parserinfo().convertyear(n)
|
||||
|
||||
|
||||
@pytest.mark.parserinfo
|
||||
@given(integers(min_value=-50,
|
||||
max_value=49))
|
||||
def test_convertyear_no_specified_century(n):
|
||||
p = parserinfo()
|
||||
new_year = p._year + n
|
||||
result = p.convertyear(new_year % 100, century_specified=False)
|
||||
assert result == new_year
|
35
lib/dateutil/test/property/test_tz_prop.py
Normal file
35
lib/dateutil/test/property/test_tz_prop.py
Normal file
|
@ -0,0 +1,35 @@
|
|||
from datetime import datetime, timedelta
|
||||
|
||||
import pytest
|
||||
import six
|
||||
from hypothesis import assume, given
|
||||
from hypothesis import strategies as st
|
||||
|
||||
from dateutil import tz as tz
|
||||
|
||||
EPOCHALYPSE = datetime.fromtimestamp(2147483647)
|
||||
NEGATIVE_EPOCHALYPSE = datetime.fromtimestamp(0) - timedelta(seconds=2147483648)
|
||||
|
||||
|
||||
@pytest.mark.gettz
|
||||
@pytest.mark.parametrize("gettz_arg", [None, ""])
|
||||
# TODO: Remove bounds when GH #590 is resolved
|
||||
@given(
|
||||
dt=st.datetimes(
|
||||
min_value=NEGATIVE_EPOCHALYPSE, max_value=EPOCHALYPSE, timezones=st.just(tz.UTC),
|
||||
)
|
||||
)
|
||||
def test_gettz_returns_local(gettz_arg, dt):
|
||||
act_tz = tz.gettz(gettz_arg)
|
||||
if isinstance(act_tz, tz.tzlocal):
|
||||
return
|
||||
|
||||
dt_act = dt.astimezone(tz.gettz(gettz_arg))
|
||||
if six.PY2:
|
||||
dt_exp = dt.astimezone(tz.tzlocal())
|
||||
else:
|
||||
dt_exp = dt.astimezone()
|
||||
|
||||
assert dt_act == dt_exp
|
||||
assert dt_act.tzname() == dt_exp.tzname()
|
||||
assert dt_act.utcoffset() == dt_exp.utcoffset()
|
Loading…
Add table
Add a link
Reference in a new issue