1. from django.contrib import admin
    
  2. from django.test import SimpleTestCase
    
  3. 
    
  4. 
    
  5. class AdminAutoDiscoverTests(SimpleTestCase):
    
  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. 
    
  11.     def test_double_call_autodiscover(self):
    
  12.         # The first time autodiscover is called, we should get our real error.
    
  13.         with self.assertRaisesMessage(Exception, "Bad admin module"):
    
  14.             admin.autodiscover()
    
  15.         # Calling autodiscover again should raise the very same error it did
    
  16.         # the first time, not an AlreadyRegistered error.
    
  17.         with self.assertRaisesMessage(Exception, "Bad admin module"):
    
  18.             admin.autodiscover()