Ticket #16366: fix_auth_context_processor_tests.diff

File fix_auth_context_processor_tests.diff, 1.8 KB (added by Jim Dalton, 13 years ago)
  • django/contrib/auth/tests/urls.py

     
    33from django.contrib.auth.urls import urlpatterns
    44from django.contrib.auth.views import password_reset
    55from django.contrib.auth.decorators import login_required
     6from django.contrib.auth.middleware import AuthenticationMiddleware
    67from django.contrib.messages.api import info
    78from django.http import HttpResponse
    89from django.shortcuts import render_to_response
     
    1718    return HttpResponse(t.render(c))
    1819
    1920def auth_processor_no_attr_access(request):
     21    # Make sure to reset session and request.user before test
     22    request.session.accessed = False
     23    if hasattr(request, '_cached_user'):
     24        del request._cached_user
     25    auth_middleware = AuthenticationMiddleware()
     26    auth_middleware.process_request(request)
     27
    2028    r1 = render_to_response('context_processors/auth_attrs_no_access.html',
    2129        RequestContext(request, {}, processors=[context_processors.auth]))
    2230    # *After* rendering, we check whether the session was accessed
     
    2432        {'session_accessed':request.session.accessed})
    2533
    2634def auth_processor_attr_access(request):
     35    # Make sure to reset session and request.user before test
     36    request.session.accessed = False
     37    if hasattr(request, '_cached_user'):
     38        del request._cached_user
     39    auth_middleware = AuthenticationMiddleware()
     40    auth_middleware.process_request(request)
     41
    2742    r1 = render_to_response('context_processors/auth_attrs_access.html',
    2843        RequestContext(request, {}, processors=[context_processors.auth]))
    2944    return render_to_response('context_processors/auth_attrs_test_access.html',
Back to Top