diff options
author | robot-piglet <robot-piglet@yandex-team.com> | 2024-03-18 15:57:16 +0300 |
---|---|---|
committer | robot-piglet <robot-piglet@yandex-team.com> | 2024-03-18 17:36:01 +0300 |
commit | 5f76bcc9d8a7d0ff624c12731027acf9a54dd5a8 (patch) | |
tree | 15ab8c78ee8a8e4e743139621d634551298db94e /contrib/python/python-dateutil/py2/tests/property/test_isoparse_prop.py | |
parent | ebc6526bccdf9d2304b9eef3a0a9eaba8e7e38f7 (diff) | |
download | ydb-5f76bcc9d8a7d0ff624c12731027acf9a54dd5a8.tar.gz |
Intermediate changes
Diffstat (limited to 'contrib/python/python-dateutil/py2/tests/property/test_isoparse_prop.py')
-rw-r--r-- | contrib/python/python-dateutil/py2/tests/property/test_isoparse_prop.py | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/contrib/python/python-dateutil/py2/tests/property/test_isoparse_prop.py b/contrib/python/python-dateutil/py2/tests/property/test_isoparse_prop.py new file mode 100644 index 0000000000..f8e288f3d6 --- /dev/null +++ b/contrib/python/python-dateutil/py2/tests/property/test_isoparse_prop.py @@ -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 |