'ensure_csrf_cookie() doesn\'t log warnings (#19436).'

def test_ensures_csrf_cookie_no_logging(self):

    class TestHandler(logging.Handler, ):
        def emit(self, record):
            raise Exception("This    shouldn't    have    happened!")
    logger = logging.getLogger('django.request')
    test_handler = TestHandler()
    old_log_level = logger.level
    try:
        logger.addHandler(test_handler)
        logger.setLevel(logging.WARNING)
        req = self._get_GET_no_csrf_cookie_request()
        ensure_csrf_cookie_view(req)
    finally:
        logger.removeHandler(test_handler)
        logger.setLevel(old_log_level)
