Advertisement
Guest User

Untitled

a guest
Mar 4th, 2015
184
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.61 KB | None | 0 0
  1. from werkzeug.routing import RequestRedirect, MethodNotAllowed, NotFound
  2.  
  3. to_test = (
  4. ('/user/1', 'GET', {}),
  5. ('/post/my-title/edit', 'POST', {}),
  6. ('/comments', 'GET', {'spam': 1}),
  7. )
  8. good = []
  9. adapter = app.create_url_adapter(None)
  10.  
  11. if adapter is None:
  12. raise Exception('configure a SERVER_NAME for the app')
  13.  
  14. for path, method, args in to_test:
  15. try:
  16. adapter.match(path, method, query_args=args)
  17. except RequestRedirect:
  18. pass
  19. except (MethodNotAllowed, NotFound):
  20. continue
  21.  
  22. good.append((path, method, args))
  23.  
  24. # good list now contains all tuples that didn't 404 or 405
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement