代码之家  ›  专栏  ›  技术社区  ›  dave mankoff

Pylons Controller Tests Don't Pass Request Params

  •  0
  • dave mankoff  · 技术社区  · 16 年前

    我们正在为我们的塔架应用程序设置控制器测试。我做了一个非常简单的控制器和一个非常简单的测试。测试结果如下:

    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
    

    Meanwhile, the controller looks something like this:

    class MainController(BaseController):
        def index(self):
            print request
            print request.params
    

    For some reason, when we run this code, we get the following output:

    -------------------- >> 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 << ----------------------
    

    The TestApp thinks its sending the proper request, but the request that hits the controller is wrong. Anyone have any idea what's going on here? We're dead in the water on tests at the moment.

    1 回复  |  直到 16 年前
        1
  •  1
  •   dave mankoff    16 年前

    根据马吕斯的评论,事实证明我们之前做了一个设置我们的应用程序的请求。那个要求是胡扯。

    推荐文章