@@ -906,24 +906,25 @@ def test_parse_delimited_date_swap(all_parsers, datestring,
906
906
min_value = date (1000 , 1 , 1 ),
907
907
max_value = date (9999 , 12 , 31 )
908
908
)
909
- _DEFAULT_DATETIME = datetime (1 , 1 , 1 ).replace (hour = 0 , minute = 0 ,
910
- second = 0 , microsecond = 0 )
909
+ _DEFAULT_DATETIME = datetime (1 , 1 , 1 )
911
910
912
911
913
912
@given (gen_random_datetime )
914
- @pytest .mark .parametrize ("date_format, delimiters, dayfirst" , [
915
- ( "%m %d %Y " , " -./" , False ),
916
- ( "%m %d %Y " , " -./" , True ),
917
- ( "%d %m %Y", " -./" , True ) ,
918
- ( "%d %m %Y" , " -./" , False ) ,
919
- ( "%m %Y" , " -/" , False ) ,
920
- ( "% m %Y" , " -/" , True )
913
+ @pytest .mark .parametrize ("delimiter" , list ( " -./" ))
914
+ @ pytest . mark . parametrize ( "dayfirst " , [ True , False ])
915
+ @ pytest . mark . parametrize ( "date_format " , [
916
+ "%m %d %Y" ,
917
+ "%d %m %Y" ,
918
+ "%m %Y" ,
919
+ "%Y % m %d"
921
920
])
922
- def test_hypothesis_delimited_date (date_format , delimiters , dayfirst , date ):
923
- date_strings = [date .strftime (date_format .replace (' ' , delim ))
924
- for delim in delimiters ]
925
- for date_string in date_strings :
926
- result = parse_datetime_string (date_string , dayfirst = dayfirst )
927
- expected = du_parse (date_string , default = _DEFAULT_DATETIME ,
928
- dayfirst = dayfirst , yearfirst = False )
929
- assert result == expected
921
+ def test_hypothesis_delimited_date (date_format , dayfirst , delimiter , date ):
922
+ if date_format == "%m %Y" and delimiter == "." :
923
+ # parse_datetime_string cannot reliably tell whether e.g. %m.%Y
924
+ # is a float or a date, thus we skip it
925
+ pytest .skip ()
926
+ date_string = date .strftime (date_format .replace (' ' , delimiter ))
927
+ result = parse_datetime_string (date_string , dayfirst = dayfirst )
928
+ expected = du_parse (date_string , default = _DEFAULT_DATETIME ,
929
+ dayfirst = dayfirst , yearfirst = False )
930
+ assert result == expected
0 commit comments