If you print out your code you will see that you are adding a key-value to the WSGI environ:
# print factory.post('/', secure=True) <WSGIRequest path:/, GET:<QueryDict: {}>, POST:<QueryDict: {}>, COOKIES:{}, META:{ ... 'PATH_INFO': u'/', ... 'REQUEST_METHOD': 'POST', ... 'SERVER_PROTOCOL': 'HTTP/1.1', 'secure': True, ... 'wsgi.url_scheme': 'http', ... > This is because factory.post has the following parameters: post(path, data={}, content_type=MULTIPART_CONTENT, follow=False, **extra) Your secure=True gets pushed into extra and it appears in the environ as expected. The solution for modeling TLS requests is to set the 'wsgi.url_scheme' to 'https' using an unpacked dictionary. # obj = factory.post('/', **{'wsgi.url_scheme': 'https'}) # print obj # print obj.is_secure() <WSGIRequest path:/, GET:<QueryDict: {}>, POST:<QueryDict: {}>, COOKIES:{}, META:{ ... 'PATH_INFO': u'/', ... 'REQUEST_METHOD': 'POST', ... 'wsgi.url_scheme': u'https', ... > True --- See line 109 https://github.com/django/django/blob/stable/1.6.x/django/core/handlers/wsgi.py K On Tuesday, May 13, 2014 1:12:46 AM UTC-7, jvc26 wrote: > > Could anyone explain what is going wrong here: > > factory = RequestFactory() > factory.post('/', secure=True).is_secure() > > Surely that should be True? > > J > -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To post to this group, send email to django-users@googlegroups.com. Visit this group at http://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/a392facb-7846-496f-aa7c-38f4ab7c50b7%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.