From d3cd9c0d0675e5067562a21b5341223ebd157761 Mon Sep 17 00:00:00 2001 From: Julien Phalip Date: Sun, 16 Oct 2011 06:57:25 +0000 Subject: [PATCH] Made an `AutoField` test more robust. git-svn-id: http://code.djangoproject.com/svn/django/trunk@16992 bcc190cf-cafb-0310-a4f2-bffc1f526a37 --- tests/modeltests/validation/models.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/tests/modeltests/validation/models.py b/tests/modeltests/validation/models.py index 2c94fefccd..5b90e4b082 100644 --- a/tests/modeltests/validation/models.py +++ b/tests/modeltests/validation/models.py @@ -93,11 +93,13 @@ class GenericIPAddrUnpackUniqueTest(models.Model): generic_v4unpack_ip = models.GenericIPAddressField(blank=True, unique=True, unpack_ipv4=True) +# A model can't have multiple AutoFields +# Refs #12467. +assertion_error = None 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 +except AssertionError, assertion_error: + pass # Fail silently +assert assertion_error.message == u"A model can't have more than one AutoField." \ No newline at end of file