Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from werkzeug.routing import RequestRedirect, MethodNotAllowed, NotFound
- to_test = (
- ('/user/1', 'GET', {}),
- ('/post/my-title/edit', 'POST', {}),
- ('/comments', 'GET', {'spam': 1}),
- )
- good = []
- adapter = app.create_url_adapter(None)
- if adapter is None:
- raise Exception('configure a SERVER_NAME for the app')
- for path, method, args in to_test:
- try:
- adapter.match(path, method, query_args=args)
- except RequestRedirect:
- pass
- except (MethodNotAllowed, NotFound):
- continue
- good.append((path, method, args))
- # good list now contains all tuples that didn't 404 or 405
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement