18
18
from pandas ._libs .tslib import Timestamp
19
19
from pandas ._libs .tslibs import parsing
20
20
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
22
22
from pandas .compat .numpy import np_array_datetime64_compat
23
23
24
24
import pandas as pd
33
33
_DEFAULT_DATETIME = datetime (1 , 1 , 1 )
34
34
35
35
# 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 ( )
40
40
41
41
42
42
def test_separator_date_conflict (all_parsers ):
@@ -908,7 +908,7 @@ def _helper_hypothesis_delimited_date(call, date_string, **kwargs):
908
908
return msg , result
909
909
910
910
911
- @given (gen_random_datetime )
911
+ @given (date_strategy )
912
912
@pytest .mark .parametrize ("delimiter" , list (" -./" ))
913
913
@pytest .mark .parametrize ("dayfirst" , [True , False ])
914
914
@pytest .mark .parametrize ("date_format" , [
@@ -920,13 +920,14 @@ def _helper_hypothesis_delimited_date(call, date_string, **kwargs):
920
920
"%Y%m%d" ,
921
921
"%y%m%d" ,
922
922
])
923
- def test_hypothesis_delimited_date (date_format , dayfirst , delimiter , date ):
923
+ def test_hypothesis_delimited_date (date_format , dayfirst ,
924
+ delimiter , test_datetime ):
924
925
if date_format == "%m %Y" and delimiter == "." :
925
926
pytest .skip ("parse_datetime_string cannot reliably tell whether \
926
927
e.g. %m.%Y is a float or a date, thus we skip it" )
927
928
result , expected = None , None
928
929
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 ))
930
931
931
932
except_out_dateutil , result = _helper_hypothesis_delimited_date (
932
933
parse_datetime_string , date_string ,
0 commit comments