【发布时间】:2019-01-20 04:54:31
【问题描述】:
我目前正在本地网络服务器上测试我的网站。
每次运行 python3 manage.py 单元测试时,本地主机端口 localhost:[port] 都会不断变化。
由于 localhost:port 在每次测试中都发生变化,它无法将 url [localhost:'port'] 与我在 Oauth 凭据中输入的重定向 url 匹配。
我如何能够运行我的单元测试并让浏览器每次都使用某个端口?
我目前正在关注 taskbuster django 教程 http://www.marinamele.com/user-authentication-with-google-using-django-allauthtaskbuster
如果您在该页面上向下滚动到以下部分 “表明http://localhost:8081 的重定向 URI 无效。这是因为我们注册了一个不同的 url,http://127.0.0.1:8000,而不是测试使用的那个。” 然后我的问题就会变得明显。
总结
1.我已注册回调地址为http:127.0.0.1:8081
-
每次我运行单元测试时,Web 服务器都会在以下 'http:127.0.0.1:53000' 或该数字的变体上运行。
- 如何让测试在指定端口上运行。
【问题讨论】:
-
使用 LiveServerTestCase 可能会有所帮助stackoverflow.com/questions/47887156/…
标签: python django localhost port