Opened 5 years ago

Closed 5 years ago

#12082 closed (duplicate)

Inclusion of new auth tests force Sites framework requirement

Reported by: thebitguru 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:

Description

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/__init__.py) 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/views.py", 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/models.py", 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/views.py@#L186 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)

views.py.diff (1.0 KB) - added by thebitguru 5 years ago.

Download all attachments as: .zip

Change History (2)

Changed 5 years ago by thebitguru

comment:1 Changed 5 years ago by Alex

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Resolution set to duplicate
  • Status changed from new to closed

Dupe of #10608.

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