【发布时间】:2014-07-23 18:55:24
【问题描述】:
我有一个 Django 1.6 项目,我正在尝试在其中运行 LiveServerTestCase。但是,我的测试用例不需要 HTTPS,所以我想禁用它。有没有办法做到这一点?
我跑:
$ website/manage.py test website/tests.py:MySeleniumTests
Firefox 打开指向:
https://localhost:8081/
我可以在 8081 端口上运行安全服务器:
$ website/manage.py runserver_plus --cert cert 0.0.0.0:8081
INSTALLED_APPS = (
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.admin',
'django.contrib.admindocs',
'django.contrib.messages',
'django.contrib.staticfiles',
'south',
'website.nucleus',
'website.blog',
'django_extensions',
'debug_toolbar',
'django_nose',
'django_coverage',
'tinymce',
'django_ztask',
'timezones',
'tracking',
'gunicorn',
'raven.contrib.django.raven_compat',
'social.apps.django_app.default',
'report_builder',
'bootstrapform',
'bootstrap3',
)
【问题讨论】:
-
你的意思是浏览器打开
https://...urls下的网页?你能展示你如何运行测试吗?谢谢。 -
感谢您的回复。我用详细信息更新了问题。
-
感谢您的更新。能否也显示
INSTALLED_APPS和MIDDLEWARE_CLASSES设置? -
当我意识到我们安装了 SSL REDIRECT 中间件时,我开始发布 MIDDLEWARE_CLASSES。我对此发表了评论,瞧,实时服务器和我的硒测试开始工作了!如果您想写:寻找 SSL REDIRECT 中间件作为答案,我很乐意将其标记为已回答。感谢您的帮助!
-
是的,这就是我问的原因,因为根据源代码,默认使用
http协议。感谢您的更新:)
标签: python django http testing https