On Jun 27, 2012, at 5:15 PM, villas wrote:
> With regards testing routes. I notice there seems to be a way of logging and
> there are some doc tests too, not that I know how they work (please forgive
> me). However, I wonder whether there is some way I can do something like
> this (all strings just random) so I can test my ideas without changing the
> routes.py and stopping and starting the server and then typing urls into the
> browser to see what happens.
>
> myroute = (r'.*/blah/foo(?P<any>.*)', r'\g<any>')
> myurl = 'adsf.com/blah/etc/test'
> show_transformed_route(myroute, myurl)
> this/is/your/blah/foo/new/route
>
> Many thanks, David
The doctests are really what you want to use, and not that hard. Just run your
routes.py with python. (Delete the existing tests that fail because you've
changed the routes from the example, or convert them to conform to your routes).
>>> filter_url('http://adsf.com/blah/etc/test')
"what you expect"
You don't even have to get "what you expect" right, since the doctest will tell
you what it actually got.