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:05:49 -0400
commit11181a64f947236402903deb6fa8c4df7b8bff75 (patch)
tree22a0b1697b1479e1582153ca67e82ba7faef23f3 /tests/admin_autodiscover
parentf14898a45308c3a46e9a742f7f7ee7869364e95b (diff)
downloaddjango-11181a64f947236402903deb6fa8c4df7b8bff75.tar.gz
Fixed #22979 -- Moved bug* tests
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")