diff --git a/pandas/tests/scalar/timestamp/test_unary_ops.py b/pandas/tests/scalar/timestamp/test_unary_ops.py index aecddab8477fc..0336ea41c4e3f 100644 --- a/pandas/tests/scalar/timestamp/test_unary_ops.py +++ b/pandas/tests/scalar/timestamp/test_unary_ops.py @@ -118,6 +118,25 @@ def test_ceil_floor_edge(self, test_input, rounder, freq, expected): expected = Timestamp(expected) assert result == expected + @pytest.mark.parametrize('test_input, freq, expected', [ + ('2018-01-01 00:02:00', '2T', '2018-01-01 00:02:00'), + ('2018-01-01 00:04:00', '4T', '2018-01-01 00:04:00'), + ('2018-01-01 00:15:00', '15T', '2018-01-01 00:15:00'), + ('2018-01-01 00:20:00', '20T', '2018-01-01 00:20:00'), + ]) + def test_round_minute_freq(self, test_input, freq, expected): + # ensure timestamps that shouldn't round don't + # GH#21262 + dt = Timestamp(test_input) + expected = Timestamp(expected) + + result_ceil = dt.ceil(freq) + assert result_ceil == expected + result_floor = dt.floor(freq) + assert result_floor == expected + result_round = dt.round(freq) + assert result_round == expected + def test_ceil(self): dt = Timestamp('20130101 09:10:11') result = dt.ceil('D')