summaryrefslogtreecommitdiff
path: root/tests/admin_autodiscover
diff options
context:
space:
mode:
authorTushar Bhatia <tushar747@gmail.com>2014-07-26 09:23:01 +0800
committerTim Graham <timograham@gmail.com>2014-07-26 21:10:03 -0400
commitdf0d5ea7bc9821923c70e7bf06d3646598cf019d (patch)
tree88fe0569b34b169e09454095b31bb082923549e0 /tests/admin_autodiscover
parent30ccb36cb9c1bc9bd30edb2b67f26ef2a1e4fb53 (diff)
[1.7.x] Fixed #22979 -- Moved bug* tests
Backport of 11181a64f from master.
Diffstat (limited to 'tests/admin_autodiscover')
-rw-r--r--tests/admin_autodiscover/__init__.py0
-rw-r--r--tests/admin_autodiscover/admin.py7
-rw-r--r--tests/admin_autodiscover/models.py5
-rw-r--r--tests/admin_autodiscover/tests.py21
4 files changed, 33 insertions, 0 deletions
diff --git a/tests/admin_autodiscover/__init__.py b/tests/admin_autodiscover/__init__.py
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/tests/admin_autodiscover/__init__.py
diff --git a/tests/admin_autodiscover/admin.py b/tests/admin_autodiscover/admin.py
new file mode 100644
index 0000000000..e7d1a080c2
--- /dev/null
+++ b/tests/admin_autodiscover/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/admin_autodiscover/models.py b/tests/admin_autodiscover/models.py
new file mode 100644
index 0000000000..a093db4bd6
--- /dev/null
+++ b/tests/admin_autodiscover/models.py
@@ -0,0 +1,5 @@
+from django.db import models
+
+
+class Story(models.Model):
+ title = models.CharField(max_length=10)
diff --git a/tests/admin_autodiscover/tests.py b/tests/admin_autodiscover/tests.py
new file mode 100644
index 0000000000..af5aebcd7f
--- /dev/null
+++ b/tests/admin_autodiscover/tests.py
@@ -0,0 +1,21 @@
+from unittest import TestCase
+
+from django.contrib import admin
+
+
+class AdminAutoDiscoverTests(TestCase):
+ """
+ Test for bug #8245 - don't raise an AlreadyRegistered exception when using
+ autodiscover() and an admin.py module contains an error.
+ """
+ def test_double_call_autodiscover(self):
+ # The first time autodiscover is called, we should get our real error.
+ with self.assertRaises(Exception) as cm:
+ admin.autodiscover()
+ self.assertEqual(str(cm.exception), "Bad admin module")
+
+ # Calling autodiscover again should raise the very same error it did
+ # the first time, not an AlreadyRegistered error.
+ with self.assertRaises(Exception) as cm:
+ admin.autodiscover()
+ self.assertEqual(str(cm.exception), "Bad admin module")