summaryrefslogtreecommitdiffstats
path: root/contrib/python/python-dateutil/py3/dateutil/test/property
diff options
context:
space:
mode:
authorshadchin <[email protected]>2023-10-10 11:35:31 +0300
committershadchin <[email protected]>2023-10-10 11:54:48 +0300
commit656bb1fb2814e586db5de6166ebbb17363d5325b (patch)
tree31b755ba74120fea597c6d00ce9ff1d0ca7b728a /contrib/python/python-dateutil/py3/dateutil/test/property
parent3896b7591b5f3231ceb4bfe69cf9863b237d8b78 (diff)
Split python-dateutil on py2/py3
Diffstat (limited to 'contrib/python/python-dateutil/py3/dateutil/test/property')
-rw-r--r--contrib/python/python-dateutil/py3/dateutil/test/property/test_isoparse_prop.py27
-rw-r--r--contrib/python/python-dateutil/py3/dateutil/test/property/test_parser_prop.py22
2 files changed, 49 insertions, 0 deletions
diff --git a/contrib/python/python-dateutil/py3/dateutil/test/property/test_isoparse_prop.py b/contrib/python/python-dateutil/py3/dateutil/test/property/test_isoparse_prop.py
new file mode 100644
index 00000000000..f8e288f3d60
--- /dev/null
+++ b/contrib/python/python-dateutil/py3/dateutil/test/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)
+
+
+@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
diff --git a/contrib/python/python-dateutil/py3/dateutil/test/property/test_parser_prop.py b/contrib/python/python-dateutil/py3/dateutil/test/property/test_parser_prop.py
new file mode 100644
index 00000000000..fdfd171e867
--- /dev/null
+++ b/contrib/python/python-dateutil/py3/dateutil/test/property/test_parser_prop.py
@@ -0,0 +1,22 @@
+from hypothesis.strategies import integers
+from hypothesis import given
+
+import pytest
+
+from dateutil.parser import parserinfo
+
+
+@given(integers(min_value=100, max_value=9999))
+def test_convertyear(n):
+ assert n == parserinfo().convertyear(n)
+
+
+@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