summaryrefslogtreecommitdiff
path: root/Windows/dateutil/test/property/test_isoparse_prop.py
diff options
context:
space:
mode:
authorrahulp132020-02-28 11:38:58 +0530
committerrahulp132020-02-28 11:38:58 +0530
commit246319682f60293b132fca1ce6e24689c6682617 (patch)
tree6871b758a17869efecfd617f5513e31f9a933f4a /Windows/dateutil/test/property/test_isoparse_prop.py
parentd9ab84106cac311d953f344386fef1c1e2bca1cf (diff)
downloadeSim-246319682f60293b132fca1ce6e24689c6682617.tar.gz
eSim-246319682f60293b132fca1ce6e24689c6682617.tar.bz2
eSim-246319682f60293b132fca1ce6e24689c6682617.zip
initial commit
Diffstat (limited to 'Windows/dateutil/test/property/test_isoparse_prop.py')
-rw-r--r--Windows/dateutil/test/property/test_isoparse_prop.py27
1 files changed, 27 insertions, 0 deletions
diff --git a/Windows/dateutil/test/property/test_isoparse_prop.py b/Windows/dateutil/test/property/test_isoparse_prop.py
new file mode 100644
index 00000000..c6a4b82a
--- /dev/null
+++ b/Windows/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.tzutc()] +
+ [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