Unit testing 塔架控制器测试Don';t通过请求参数

Unit testing 塔架控制器测试Don';t通过请求参数,unit-testing,pylons,functional-testing,Unit Testing,Pylons,Functional Testing,我们正在尝试为我们的挂架应用程序设置控制器测试。我做了一个非常简单的控制器和一个非常简单的测试。这些测试看起来像: class TestMainController(TestController): def test_index(self): response = self.app.get(url(controller='main', action='index', var1 = '1'), params={'var2':'2'}) print respo

我们正在尝试为我们的挂架应用程序设置控制器测试。我做了一个非常简单的控制器和一个非常简单的测试。这些测试看起来像:

class TestMainController(TestController):
    def test_index(self):
        response = self.app.get(url(controller='main', action='index', var1 = '1'), params={'var2':'2'})
        print response.req
        assert False
同时,控制器看起来像这样:

class MainController(BaseController):
    def index(self):
        print request
        print request.params
出于某种原因,当我们运行此代码时,会得到以下输出:

-------------------- >> begin captured stdout << ---------------------
GET /_test_vars HTTP/1.0
Host: localhost:80
<Request at 0x36d6950 GET http://localhost/_test_vars>
UnicodeMultiDict([])
GET /main/index/?var1=1&var2=2 HTTP/1.0
Host: localhost:80

--------------------- >> end captured stdout << ----------------------

------------->>开始捕获的标准输出>结束捕获的标准输出根据马吕斯的评论,原来我们在做一个较早的请求来设置我们的应用程序。这个请求很麻烦。

在新创建的Pylons 1.0项目中,这段代码对我来说很好。这一定是您在代码的其他地方所做的事情。如何在主控制器中导入“请求”?您是否在测试设置中的某个位置进行了任何特殊设置(例如请求、推送或对象)?