summaryrefslogtreecommitdiff
path: root/tests/modeltests/model_forms
diff options
context:
space:
mode:
authorKaren Tracey <kmtracey@gmail.com>2009-12-17 15:10:38 +0000
committerKaren Tracey <kmtracey@gmail.com>2009-12-17 15:10:38 +0000
commit5bd63663a9754ef783aa21402f534fe6ed45ef57 (patch)
treee12689d4bf10f59b135dbb627b1ecb0b9d5a092c /tests/modeltests/model_forms
parentfd4cc65baf7055e7815513756a3d3f6940c1d2ab (diff)
Fixed #399: Added big integer field. Thanks to Tomáš Kopeček for persistently maintaining a patch for this.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@11887 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'tests/modeltests/model_forms')
-rw-r--r--tests/modeltests/model_forms/models.py34
1 files changed, 28 insertions, 6 deletions
diff --git a/tests/modeltests/model_forms/models.py b/tests/modeltests/model_forms/models.py
index 0fd24c18ad..c94e6d3e95 100644
--- a/tests/modeltests/model_forms/models.py
+++ b/tests/modeltests/model_forms/models.py
@@ -13,12 +13,6 @@ import tempfile
from django.db import models
from django.core.files.storage import FileSystemStorage
-# Python 2.3 doesn't have sorted()
-try:
- sorted
-except NameError:
- from django.utils.itercompat import sorted
-
temp_storage_dir = tempfile.mkdtemp()
temp_storage = FileSystemStorage(temp_storage_dir)
@@ -201,6 +195,12 @@ class Post(models.Model):
def __unicode__(self):
return self.name
+class BigInt(models.Model):
+ biggie = models.BigIntegerField()
+
+ def __unicode__(self):
+ return unicode(self.biggie)
+
__test__ = {'API_TESTS': """
>>> from django import forms
>>> from django.forms.models import ModelForm, model_to_dict
@@ -1145,6 +1145,28 @@ True
# Delete the current file since this is not done by Django.
>>> instance.file.delete()
>>> instance.delete()
+
+# BigIntegerField ################################################################
+>>> class BigIntForm(forms.ModelForm):
+... class Meta:
+... model = BigInt
+...
+>>> bif = BigIntForm({'biggie': '-9223372036854775808'})
+>>> bif.is_valid()
+True
+>>> bif = BigIntForm({'biggie': '-9223372036854775809'})
+>>> bif.is_valid()
+False
+>>> bif.errors
+{'biggie': [u'Ensure this value is greater than or equal to -9223372036854775808.']}
+>>> bif = BigIntForm({'biggie': '9223372036854775807'})
+>>> bif.is_valid()
+True
+>>> bif = BigIntForm({'biggie': '9223372036854775808'})
+>>> bif.is_valid()
+False
+>>> bif.errors
+{'biggie': [u'Ensure this value is less than or equal to 9223372036854775807.']}
"""}
if test_images: