summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorJulien Phalip <jphalip@gmail.com>2011-10-13 11:53:59 +0000
committerJulien Phalip <jphalip@gmail.com>2011-10-13 11:53:59 +0000
commitc58e5724bcebc74ccfbc49a4a29de6fd0fa6103e (patch)
tree96d2afb17be9acfb3b395d69e72c3d9b6f5754a8 /tests
parent639400d52fe4c364d91ec67cdb58a3174d33e8ad (diff)
Fixed a couple of `assert` syntax warnings mistakingly introduced in r16966 and added some tests to prevent future regressions. Thanks to Anssi Kääriäinen for the report.
Refs #12467. git-svn-id: http://code.djangoproject.com/svn/django/trunk@16971 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'tests')
-rw-r--r--tests/modeltests/validation/models.py10
-rw-r--r--tests/modeltests/validation/test_error_messages.py6
2 files changed, 16 insertions, 0 deletions
diff --git a/tests/modeltests/validation/models.py b/tests/modeltests/validation/models.py
index fca2cef261..182e739daf 100644
--- a/tests/modeltests/validation/models.py
+++ b/tests/modeltests/validation/models.py
@@ -90,3 +90,13 @@ class GenericIPAddressTestModel(models.Model):
class GenericIPAddrUnpackUniqueTest(models.Model):
generic_v4unpack_ip = models.GenericIPAddressField(blank=True, unique=True, unpack_ipv4=True)
+
+
+try:
+ # A model can't have multiple AutoFields
+ # Refs #12467.
+ class MultipleAutoFields(models.Model):
+ auto1 = models.AutoField(primary_key=True)
+ auto2 = models.AutoField(primary_key=True)
+except AssertionError, e:
+ assert e.message == u"A model can't have more than one AutoField." \ No newline at end of file
diff --git a/tests/modeltests/validation/test_error_messages.py b/tests/modeltests/validation/test_error_messages.py
index 43b707e632..299a93a41a 100644
--- a/tests/modeltests/validation/test_error_messages.py
+++ b/tests/modeltests/validation/test_error_messages.py
@@ -12,6 +12,12 @@ class ValidationMessagesTest(TestCase):
f.clean('foo', None)
except ValidationError, e:
self.assertEqual(e.messages, [u"'foo' value must be an integer."])
+ # primary_key must be True. Refs #12467.
+ self.assertRaises(AssertionError, models.AutoField, 'primary_key', False)
+ try:
+ models.AutoField(primary_key=False)
+ except AssertionError, e:
+ self.assertEqual(e.message, u"AutoFields must have primary_key=True.")
def test_integer_field_raises_error_message(self):
f = models.IntegerField()