def test_from_interval(self): assert TimeUnit.from_interval('2second').as_tuple() == (2, SECOND) assert TimeUnit.from_interval('2.5second').as_tuple() == (2.5, SECOND)
def test_from_interval_invalid(self): inputs = [None, '', 'minute1', '-1minute', '2meter'] for i in inputs: with pytest.raises(ValueError): TimeUnit.from_interval(i)