Opened 7 years ago

Closed 7 years ago

#12082 closed (duplicate)

Inclusion of new auth tests force Sites framework requirement

Reported by: Farhan Ahmad Owned by: nobody
Component: contrib.auth Version: 1.1
Severity: Keywords:
Cc: farhan@… Triage Stage: Unreviewed
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:


After upgrading to 1.1.1 I noticed that the inclusion of auth tests (specifically django.contrib.auth.tests.views.LoginTest imported in source:django/trunk/django/contrib/auth/tests/ cause the test framework to throw an exception if you are not using the Sites framework. Here is the exception raised, which includes the specific references.

ERROR: test_current_site_in_context_after_login (django.contrib.auth.tests.views.LoginTest)
Traceback (most recent call last):
  File "/sto/imp/dev/django/Django-1.1.1/django/contrib/auth/tests/", line 191, in test_current_site_in_context_after_login
    site = Site.objects.get_current()
  File "/sto/imp/dev/django/Django-1.1.1/django/contrib/sites/", line 18, in get_current
    raise ImproperlyConfigured("You're using the Django \"sites framework\" without having set the SITE_ID setting.
                                Create a site in your database and set the SITE_ID setting to fix this error.")
ImproperlyConfigured: You're using the Django "sites framework" without having set the SITE_ID setting.
                      Create a site in your database and set the SITE_ID setting to fix this error.


I realize that I can specify the individual applications in the test command to prevent this, but I think this should be fixed in the base code. The problem is in source:django/trunk/django/contrib/auth/tests/ LoginTest.test_current_site_in_context_after_login where it doesn't check whether the Sites framwork is installed.

    def test_current_site_in_context_after_login(self):
        response = self.client.get(reverse('django.contrib.auth.views.login'))
        self.assertEquals(response.status_code, 200)
        site = Site.objects.get_current()

I am attaching a diff file with my proposed fix.

Attachments (1) (1.0 KB) - added by Farhan Ahmad 7 years ago.

Download all attachments as: .zip

Change History (2)

Changed 7 years ago by Farhan Ahmad

Attachment: added

comment:1 Changed 7 years ago by Alex Gaynor

Needs documentation: unset
Needs tests: unset
Patch needs improvement: unset
Resolution: duplicate
Status: newclosed

Dupe of #10608.

Note: See TracTickets for help on using tickets.
Back to Top