PageRenderTime 14ms CodeModel.GetById 0ms RepoModel.GetById 0ms 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
Possible License(s): BSD-3-Clause
  1. from django.contrib import admin
  2. from django.utils.unittest import TestCase
  3. class Bug8245Test(TestCase):
  4. """
  5. Test for bug #8245 - don't raise an AlreadyRegistered exception when using
  6. autodiscover() and an admin.py module contains an error.
  7. """
  8. def test_bug_8245(self):
  9. # The first time autodiscover is called, we should get our real error.
  10. try:
  11. admin.autodiscover()
  12. except Exception, e:
  13. self.assertEqual(str(e), "Bad admin module")
  14. else:
  15. self.fail(
  16. 'autodiscover should have raised a "Bad admin module" error.')
  17. # Calling autodiscover again should raise the very same error it did
  18. # the first time, not an AlreadyRegistered error.
  19. try:
  20. admin.autodiscover()
  21. except Exception, e:
  22. self.assertEqual(str(e), "Bad admin module")
  23. else:
  24. self.fail(
  25. 'autodiscover should have raised a "Bad admin module" error.')