diff options
author | Tushar Bhatia <tushar747@gmail.com> | 2014-07-26 09:23:01 +0800 |
---|---|---|
committer | Tim Graham <timograham@gmail.com> | 2014-07-26 21:05:49 -0400 |
commit | 11181a64f947236402903deb6fa8c4df7b8bff75 (patch) | |
tree | 22a0b1697b1479e1582153ca67e82ba7faef23f3 /tests/admin_autodiscover | |
parent | f14898a45308c3a46e9a742f7f7ee7869364e95b (diff) | |
download | django-11181a64f947236402903deb6fa8c4df7b8bff75.tar.gz |
Fixed #22979 -- Moved bug* tests
Diffstat (limited to 'tests/admin_autodiscover')
-rw-r--r-- | tests/admin_autodiscover/__init__.py | 0 | ||||
-rw-r--r-- | tests/admin_autodiscover/admin.py | 7 | ||||
-rw-r--r-- | tests/admin_autodiscover/models.py | 5 | ||||
-rw-r--r-- | tests/admin_autodiscover/tests.py | 21 |
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") |