From aefbdbcf644443d60a23e353713c186e1a64d08a Mon Sep 17 00:00:00 2001 From: Spencer Clark Date: Sun, 28 Oct 2018 08:18:22 -0400 Subject: [PATCH] Remove tests where answers change in cftime 1.0.2.1 --- xarray/tests/test_coding_times.py | 38 ++++++++++++++----------------- 1 file changed, 17 insertions(+), 21 deletions(-) diff --git a/xarray/tests/test_coding_times.py b/xarray/tests/test_coding_times.py index 8e47bd37eac..f76b8c3ceab 100644 --- a/xarray/tests/test_coding_times.py +++ b/xarray/tests/test_coding_times.py @@ -576,28 +576,24 @@ def test_infer_datetime_units(dates, expected): assert expected == coding.times.infer_datetime_units(dates) +_CFTIME_DATETIME_UNITS_TESTS = [ + ([(1900, 1, 1), (1900, 1, 1)], 'days since 1900-01-01 00:00:00.000000'), + ([(1900, 1, 1), (1900, 1, 2), (1900, 1, 2, 0, 0, 1)], + 'seconds since 1900-01-01 00:00:00.000000'), + ([(1900, 1, 1), (1900, 1, 8), (1900, 1, 16)], + 'days since 1900-01-01 00:00:00.000000') +] + + @pytest.mark.skipif(not has_cftime_or_netCDF4, reason='cftime not installed') -def test_infer_cftime_datetime_units(): - date_types = _all_cftime_date_types() - for date_type in date_types.values(): - for dates, expected in [ - ([date_type(1900, 1, 1), - date_type(1900, 1, 2)], - 'days since 1900-01-01 00:00:00.000000'), - ([date_type(1900, 1, 1, 12), - date_type(1900, 1, 1, 13)], - 'seconds since 1900-01-01 12:00:00.000000'), - ([date_type(1900, 1, 1), - date_type(1900, 1, 2), - date_type(1900, 1, 2, 0, 0, 1)], - 'seconds since 1900-01-01 00:00:00.000000'), - ([date_type(1900, 1, 1), - date_type(1900, 1, 2, 0, 0, 0, 5)], - 'days since 1900-01-01 00:00:00.000000'), - ([date_type(1900, 1, 1), date_type(1900, 1, 8), - date_type(1900, 1, 16)], - 'days since 1900-01-01 00:00:00.000000')]: - assert expected == coding.times.infer_datetime_units(dates) +@pytest.mark.parametrize( + 'calendar', _NON_STANDARD_CALENDARS + ['gregorian', 'proleptic_gregorian']) +@pytest.mark.parametrize(('date_args', 'expected'), + _CFTIME_DATETIME_UNITS_TESTS) +def test_infer_cftime_datetime_units(calendar, date_args, expected): + date_type = _all_cftime_date_types()[calendar] + dates = [date_type(*args) for args in date_args] + assert expected == coding.times.infer_datetime_units(dates) @pytest.mark.parametrize(