Skip to content

Commit d0bfd91

Browse files
committed
using is_platform_windows() in date_strategy definition; changed date -> test_datetime
1 parent 7113c75 commit d0bfd91

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

pandas/tests/io/parser/test_parse_dates.py

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
from pandas._libs.tslib import Timestamp
1919
from pandas._libs.tslibs import parsing
2020
from pandas._libs.tslibs.parsing import parse_datetime_string
21-
from pandas.compat import lrange, parse_date
21+
from pandas.compat import lrange, parse_date, is_platform_windows
2222
from pandas.compat.numpy import np_array_datetime64_compat
2323

2424
import pandas as pd
@@ -33,10 +33,10 @@
3333
_DEFAULT_DATETIME = datetime(1, 1, 1)
3434

3535
# Strategy for hypothesis
36-
gen_random_datetime = st.dates(
37-
min_value=date(1900, 1, 1), # on Windows for %y need: year > 1900
38-
max_value=date(9999, 12, 31)
39-
)
36+
if is_platform_windows():
37+
date_strategy = st.datetimes(min_value=datetime(1900, 1, 1))
38+
else:
39+
date_strategy = st.datetimes()
4040

4141

4242
def test_separator_date_conflict(all_parsers):
@@ -908,7 +908,7 @@ def _helper_hypothesis_delimited_date(call, date_string, **kwargs):
908908
return msg, result
909909

910910

911-
@given(gen_random_datetime)
911+
@given(date_strategy)
912912
@pytest.mark.parametrize("delimiter", list(" -./"))
913913
@pytest.mark.parametrize("dayfirst", [True, False])
914914
@pytest.mark.parametrize("date_format", [
@@ -920,13 +920,14 @@ def _helper_hypothesis_delimited_date(call, date_string, **kwargs):
920920
"%Y%m%d",
921921
"%y%m%d",
922922
])
923-
def test_hypothesis_delimited_date(date_format, dayfirst, delimiter, date):
923+
def test_hypothesis_delimited_date(date_format, dayfirst,
924+
delimiter, test_datetime):
924925
if date_format == "%m %Y" and delimiter == ".":
925926
pytest.skip("parse_datetime_string cannot reliably tell whether \
926927
e.g. %m.%Y is a float or a date, thus we skip it")
927928
result, expected = None, None
928929
except_in_dateutil, except_out_dateutil = None, None
929-
date_string = date.strftime(date_format.replace(' ', delimiter))
930+
date_string = test_datetime.strftime(date_format.replace(' ', delimiter))
930931

931932
except_out_dateutil, result = _helper_hypothesis_delimited_date(
932933
parse_datetime_string, date_string,

0 commit comments

Comments
 (0)