Tutorial :Pylons Controller Tests Don't Pass Request Params


We're trying to setup controller tests for our Pylons app. I made a very simple controller and a very simple test. The tests looks like:

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.


As per Marius's comment, it turns out we were doing an earlier requset to setup a our app. That request was screwing with things.

Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Next Post »