'The cache middleware shouldn\'t cause a session access due to
CACHE_MIDDLEWARE_ANONYMOUS_ONLY if nothing else has accessed the
session. Refs 13283'

def test_cache_middleware_anonymous_only_wont_cause_session_access(self):

    settings.CACHE_MIDDLEWARE_ANONYMOUS_ONLY = True
    from django.contrib.sessions.middleware import SessionMiddleware
    from django.contrib.auth.middleware import AuthenticationMiddleware
    middleware = CacheMiddleware()
    session_middleware = SessionMiddleware()
    auth_middleware = AuthenticationMiddleware()
    request = self.factory.get('/view_anon/')
    session_middleware.process_request(request)
    auth_middleware.process_request(request)
    result = middleware.process_request(request)
    self.assertEqual(result, None)
    response = hello_world_view(request, '1')
    session_middleware.process_response(request, response)
    response = middleware.process_response(request, response)
    self.assertEqual(request.session.accessed, False)
