@@ -576,28 +576,24 @@ def test_infer_datetime_units(dates, expected):
576
576
assert expected == coding .times .infer_datetime_units (dates )
577
577
578
578
579
+ _CFTIME_DATETIME_UNITS_TESTS = [
580
+ ([(1900 , 1 , 1 ), (1900 , 1 , 1 )], 'days since 1900-01-01 00:00:00.000000' ),
581
+ ([(1900 , 1 , 1 ), (1900 , 1 , 2 ), (1900 , 1 , 2 , 0 , 0 , 1 )],
582
+ 'seconds since 1900-01-01 00:00:00.000000' ),
583
+ ([(1900 , 1 , 1 ), (1900 , 1 , 8 ), (1900 , 1 , 16 )],
584
+ 'days since 1900-01-01 00:00:00.000000' )
585
+ ]
586
+
587
+
579
588
@pytest .mark .skipif (not has_cftime_or_netCDF4 , reason = 'cftime not installed' )
580
- def test_infer_cftime_datetime_units ():
581
- date_types = _all_cftime_date_types ()
582
- for date_type in date_types .values ():
583
- for dates , expected in [
584
- ([date_type (1900 , 1 , 1 ),
585
- date_type (1900 , 1 , 2 )],
586
- 'days since 1900-01-01 00:00:00.000000' ),
587
- ([date_type (1900 , 1 , 1 , 12 ),
588
- date_type (1900 , 1 , 1 , 13 )],
589
- 'seconds since 1900-01-01 12:00:00.000000' ),
590
- ([date_type (1900 , 1 , 1 ),
591
- date_type (1900 , 1 , 2 ),
592
- date_type (1900 , 1 , 2 , 0 , 0 , 1 )],
593
- 'seconds since 1900-01-01 00:00:00.000000' ),
594
- ([date_type (1900 , 1 , 1 ),
595
- date_type (1900 , 1 , 2 , 0 , 0 , 0 , 5 )],
596
- 'days since 1900-01-01 00:00:00.000000' ),
597
- ([date_type (1900 , 1 , 1 ), date_type (1900 , 1 , 8 ),
598
- date_type (1900 , 1 , 16 )],
599
- 'days since 1900-01-01 00:00:00.000000' )]:
600
- assert expected == coding .times .infer_datetime_units (dates )
589
+ @pytest .mark .parametrize (
590
+ 'calendar' , _NON_STANDARD_CALENDARS + ['gregorian' , 'proleptic_gregorian' ])
591
+ @pytest .mark .parametrize (('date_args' , 'expected' ),
592
+ _CFTIME_DATETIME_UNITS_TESTS )
593
+ def test_infer_cftime_datetime_units (calendar , date_args , expected ):
594
+ date_type = _all_cftime_date_types ()[calendar ]
595
+ dates = [date_type (* args ) for args in date_args ]
596
+ assert expected == coding .times .infer_datetime_units (dates )
601
597
602
598
603
599
@pytest .mark .parametrize (
0 commit comments