aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/python/python-dateutil/py2/tests/property/test_tz_prop.py
diff options
context:
space:
mode:
authorrobot-piglet <robot-piglet@yandex-team.com>2024-03-18 15:57:16 +0300
committerrobot-piglet <robot-piglet@yandex-team.com>2024-03-18 17:36:01 +0300
commit5f76bcc9d8a7d0ff624c12731027acf9a54dd5a8 (patch)
tree15ab8c78ee8a8e4e743139621d634551298db94e /contrib/python/python-dateutil/py2/tests/property/test_tz_prop.py
parentebc6526bccdf9d2304b9eef3a0a9eaba8e7e38f7 (diff)
downloadydb-5f76bcc9d8a7d0ff624c12731027acf9a54dd5a8.tar.gz
Intermediate changes
Diffstat (limited to 'contrib/python/python-dateutil/py2/tests/property/test_tz_prop.py')
-rw-r--r--contrib/python/python-dateutil/py2/tests/property/test_tz_prop.py35
1 files changed, 35 insertions, 0 deletions
diff --git a/contrib/python/python-dateutil/py2/tests/property/test_tz_prop.py b/contrib/python/python-dateutil/py2/tests/property/test_tz_prop.py
new file mode 100644
index 0000000000..ec6d271dcf
--- /dev/null
+++ b/contrib/python/python-dateutil/py2/tests/property/test_tz_prop.py
@@ -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()