def test_coerce_interval(): """Test coerce_interval.""" validator = VDR() # The good for value, result in [('', None), ('P3D', DurationFloat(259200)), ('PT10M10S', DurationFloat(610))]: assert validator.coerce_interval(value, ['whatever']) == result # The bad for value in ['None', '5 days', '20', '-12']: with pytest.raises(IllegalValueError): validator.coerce_interval(value, ['whatever'])
def test_coerce_interval(self): """Test coerce_interval.""" validator = VDR() # The good for value, result in [('', None), ('P3D', DurationFloat(259200)), ('PT10M10S', DurationFloat(610))]: self.assertEqual(validator.coerce_interval(value, ['whatever']), result) # The bad for value in ['None', '5 days', '20', '-12']: self.assertRaises(IllegalValueError, validator.coerce_interval, value, ['whatever'])
def test_coerce_interval(self): """Test coerce_interval.""" validator = VDR() # The good for value, result in [ ('', None), ('P3D', DurationFloat(259200)), ('PT10M10S', DurationFloat(610))]: self.assertEqual( validator.coerce_interval(value, ['whatever']), result) # The bad for value in ['None', '5 days', '20', '-12']: self.assertRaises( IllegalValueError, validator.coerce_interval, value, ['whatever'])