Ryan Petrello wrote: > I've got an issue that I've been struggling to solve for a few days > now. I'm working with another developer on a Turbogears (version 2) > project and we're wanting to write some functional unit tests for the > controllers. Thus far, I've successfully implemented the approach > found at: > > http://wiki.pylonshq.com/display/pylonsdocs/Unit+Testing > > ...for some simple unit testing of our controllers. > > This approach returns results, but they've been generated into the > appropriate templates as a paste Response object. For unit testing, > it would be ideal if we could actually "call" the controller methods > we're testing and make assertions against their actual return values > (as it's much easier to make assertions against a simple dictionary > rather than the generated HTML output of the template! A similar > feature is available in the first version of Turbogears, and is > illustrated here: > > http://docs.turbogears.org/1.0/Testing#testing-your-controller > > I'd like to reproduce this functionality in Pylons and/or Turbogears2, > but am not really sure the best direction to go, as my knowledge of > Pylons internals is fair at best. Perhaps such functionality is > actually already available, and I've not yet stumbled upon it? Can > anyone give me some general insight, advice, or direction?
This is covered some here: http://wiki.pylonshq.com/display/pylonsdocs/Unit+Testing#testing-pylons-objects Specifically resp.c will contain template variables in Pylons. In TG 2 I'm not sure if they've hooked that up (if they haven't then they should). To set variables on the response object you would write to the dictionary environ['paste.testing_variables'] (if that key is present). Anything in that dictionary shows up as an attribute on the test response object. So you get rendered templates (which at least serves as a smoke test for valid templates) as well as the intermediate values used to produce the response. -- Ian Bicking : [EMAIL PROTECTED] : http://blog.ianbicking.org --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "pylons-discuss" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/pylons-discuss?hl=en -~----------~----~----~----~------~----~------~--~---
