def test_decimal_places_validation_errors(self): """ Test decimal specific validation. In django 1.8 this happens in validate() but once support for 1.8 is dropped it will be in run_validators, so this test uses clean() """ field = DecimalFractionField(max_digits=3, decimal_places=2) with self.assertRaises(ValidationError): # too many non-decimal digits field.clean('10') with self.assertRaises(ValidationError): # too many decimal digits field.clean('1/100')
def test_to_python_method_validation_errors(self): """ Exceptions here are tested for and raised from within to_python() """ field = DecimalFractionField() with self.assertRaises(ValidationError): field.clean('abcd') with self.assertRaises(ValidationError): field.clean('1 1 1/3') with self.assertRaises(ValidationError): field.clean('1 1')