summaryrefslogtreecommitdiff
path: root/tests/regressiontests
diff options
context:
space:
mode:
authorGary Wilson Jr <gary.wilson@gmail.com>2008-12-23 18:28:22 +0000
committerGary Wilson Jr <gary.wilson@gmail.com>2008-12-23 18:28:22 +0000
commit3abbb455b2141b4733ac3eb8cb52c826b15c07fd (patch)
tree22427595517bc19fd6b8add51ef7a1b58fd4f863 /tests/regressiontests
parent9841776ec3dde024c244631ae13da7c24b927f5b (diff)
[1.0.X] Fixed #8245 -- Added a LOADING flag to autodiscover to prevent an admin.py module with errors from raising a spurious AlreadyRegistered exception in a subsequent call to autodiscover.
Backport of r9680 from trunk. git-svn-id: http://code.djangoproject.com/svn/django/branches/releases/1.0.X@9681 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'tests/regressiontests')
-rw-r--r--tests/regressiontests/bug8245/__init__.py0
-rw-r--r--tests/regressiontests/bug8245/admin.py7
-rw-r--r--tests/regressiontests/bug8245/models.py4
-rw-r--r--tests/regressiontests/bug8245/tests.py23
4 files changed, 34 insertions, 0 deletions
diff --git a/tests/regressiontests/bug8245/__init__.py b/tests/regressiontests/bug8245/__init__.py
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/tests/regressiontests/bug8245/__init__.py
diff --git a/tests/regressiontests/bug8245/admin.py b/tests/regressiontests/bug8245/admin.py
new file mode 100644
index 0000000000..18122696b6
--- /dev/null
+++ b/tests/regressiontests/bug8245/admin.py
@@ -0,0 +1,7 @@
+from django.contrib import admin
+
+from models import Story
+
+
+admin.site.register(Story)
+raise Exception("Bad admin module")
diff --git a/tests/regressiontests/bug8245/models.py b/tests/regressiontests/bug8245/models.py
new file mode 100644
index 0000000000..5643955df3
--- /dev/null
+++ b/tests/regressiontests/bug8245/models.py
@@ -0,0 +1,4 @@
+from django.db import models
+
+class Story(models.Model):
+ title = models.CharField(max_length=10)
diff --git a/tests/regressiontests/bug8245/tests.py b/tests/regressiontests/bug8245/tests.py
new file mode 100644
index 0000000000..c1cc3b595c
--- /dev/null
+++ b/tests/regressiontests/bug8245/tests.py
@@ -0,0 +1,23 @@
+from unittest import TestCase
+
+from django.contrib import admin
+
+
+class Bug8245Test(TestCase):
+ """
+ Test for bug #8245 - don't raise an AlreadyRegistered exception when using
+ autodiscover() and an admin.py module contains an error.
+ """
+
+ def test_bug_8245(self):
+ # The first time autodiscover is called, we should get our real error.
+ try:
+ admin.autodiscover()
+ except Exception, e:
+ self.failUnlessEqual(str(e), "Bad admin module")
+ else:
+ self.fail(
+ 'autodiscover should have raised a "Bad admin module" error.')
+ # Calling autodiscover again should bail out early and not raise an
+ # AlreadyRegistered error.
+ admin.autodiscover()