equal
deleted
inserted
replaced
|
1 from unittest import TestCase |
|
2 |
|
3 from django.contrib import admin |
|
4 |
|
5 |
|
6 class Bug8245Test(TestCase): |
|
7 """ |
|
8 Test for bug #8245 - don't raise an AlreadyRegistered exception when using |
|
9 autodiscover() and an admin.py module contains an error. |
|
10 """ |
|
11 def test_bug_8245(self): |
|
12 # The first time autodiscover is called, we should get our real error. |
|
13 try: |
|
14 admin.autodiscover() |
|
15 except Exception, e: |
|
16 self.assertEqual(str(e), "Bad admin module") |
|
17 else: |
|
18 self.fail( |
|
19 'autodiscover should have raised a "Bad admin module" error.') |
|
20 |
|
21 # Calling autodiscover again should raise the very same error it did |
|
22 # the first time, not an AlreadyRegistered error. |
|
23 try: |
|
24 admin.autodiscover() |
|
25 except Exception, e: |
|
26 self.assertEqual(str(e), "Bad admin module") |
|
27 else: |
|
28 self.fail( |
|
29 'autodiscover should have raised a "Bad admin module" error.') |