Skip to content

Commit

Permalink
Fixed call to ugettext, which is imported as _.
Browse files Browse the repository at this point in the history
Changed raise to conform to PEP 3109 and wrapped the long line.
Added beginnings of tests for model fields.


git-svn-id: http://code.djangoproject.com/svn/django/trunk@5778 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information
gdub committed Jul 30, 2007
1 parent d76e532 commit f27774e
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 1 deletion.
3 changes: 2 additions & 1 deletion django/db/models/fields/__init__.py
Expand Up @@ -620,7 +620,8 @@ def to_python(self, value):
try:
return decimal.Decimal(value)
except decimal.InvalidOperation:
raise validators.ValidationError, ugettext("This value must be a decimal number.")
raise validators.ValidationError(
_("This value must be a decimal number."))

def _format(self, value):
if isinstance(value, basestring):
Expand Down
Empty file.
Empty file.
18 changes: 18 additions & 0 deletions tests/regressiontests/model_fields/tests.py
@@ -0,0 +1,18 @@
"""
>>> from django.db.models.fields import *
# DecimalField
>>> f = DecimalField()
>>> f.to_python(3)
Decimal("3")
>>> f.to_python("3.14")
Decimal("3.14")
>>> f.to_python("abc")
Traceback (most recent call last):
...
ValidationError: [u'This value must be a decimal number.']
"""

0 comments on commit f27774e

Please sign in to comment.