编程语言
首页 > 编程语言> > python webtest端口配置?

python webtest端口配置?

作者:互联网

我试图用webtest编写一些测试来测试我的python GAE应用程序.我遇到的问题是应用程序正在侦听端口8080但我无法配置webtest来命中该端口.

例如,我想使用app.get(‘/ getreport’)来达到http://localhost:8080/getreport.显然,它只会遇到http:// localhost / getreport.

有没有办法设置webtest来击中特定端口?

解决方法:

config,我引用,

port

Required? No, defaults is “80”

Defines the port number to use for
executing requests, e.g. “8080”.

编辑:用户澄清他们的意思是this webtest(pythonpaste),而不是广泛使用的Canoo应用程序.我不会猜到,因为pythonpaste的webtest是一个非常不同的鱼,我引用…:

With this you can test your web
applications without starting an HTTP
server, and without poking into the
web framework shortcutting pieces of
your application that need to be
tested. The tests WebTest runs are
entirely equivalent to how a WSGI HTTP
server would call an application

没有启动HTTP服务器,没有“端口”的概念 – 在WSGI级别的进程中运行,没有实际的TCP / IP和HTTP.因此,“应用程序”不会侦听端口8080(或任何其他端口),而是直接调用其WSGI入口点,“就好像”HTTP服务器正在调用它们一样.

如果你想测试一个实际运行的HTTP服务器,那么你需要Canoo的webtest(或其他等效的框架),而不是pythonpaste – 后者将通过避免任何套接字层和HTTP层开销来实现更快的测试,但你可以’以这种方式测试一个单独的,现有的,运行的服务器(例如GAE的SDK).

标签:python,google-app-engine,webtest
来源: https://codeday.me/bug/20190610/1213422.html