PageRenderTime 451ms CodeModel.GetById 271ms app.highlight 2ms RepoModel.GetById 175ms app.codeStats 0ms

/tests/regressiontests/bug8245/tests.py

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