def granularity(self, value): time_delta = time_utils.parse_duration(value) self._granularity = time_delta
def test_downsample_resolution(self, millis): delta = timedelta(milliseconds=millis, microseconds=5) with pytest.warns(UserWarning): duration = time_utils.parse_duration(delta) assert duration == timedelta(milliseconds=millis)
def test_parse_duration_delta(self, millis): delta = timedelta(milliseconds=millis) duration = time_utils.parse_duration(delta) assert duration == delta
def test_parse_zero(self): zero_dur = time_utils.parse_duration(0) assert isinstance(zero_dur, timedelta)
def test_parse_duration(self): one_day = time_utils.parse_duration("1d") assert one_day == timedelta(days=1)
def test_round_trip_from_delta(self, millis): delta = timedelta(milliseconds=millis) delta_millis = time_utils.duration_millis(delta) delta_parsed = time_utils.parse_duration(delta_millis) assert delta == delta_parsed