pep8 fixes
This commit is contained in:
parent
fca0221d91
commit
c3c7964e2e
|
@ -62,7 +62,9 @@ class Sanic:
|
|||
|
||||
def add_route(self, handler, uri, methods=None):
|
||||
"""
|
||||
A helper method to register class instance or functions as a handler to the application url routes.
|
||||
A helper method to register class instance or
|
||||
functions as a handler to the application url
|
||||
routes.
|
||||
:param handler: function or class instance
|
||||
:param uri: path of the URL
|
||||
:param methods: list or tuple of methods allowed
|
||||
|
|
|
@ -16,7 +16,8 @@ async def local_request(method, uri, cookies=None, *args, **kwargs):
|
|||
|
||||
|
||||
def sanic_endpoint_test(app, method='get', uri='/', gather_request=True,
|
||||
loop=None, debug=False, *request_args, **request_kwargs):
|
||||
loop=None, debug=False, *request_args,
|
||||
**request_kwargs):
|
||||
results = []
|
||||
exceptions = []
|
||||
|
||||
|
@ -34,7 +35,8 @@ def sanic_endpoint_test(app, method='get', uri='/', gather_request=True,
|
|||
exceptions.append(e)
|
||||
app.stop()
|
||||
|
||||
app.run(host=HOST, debug=debug, port=42101, after_start=_collect_response, loop=loop)
|
||||
app.run(host=HOST, debug=debug, port=42101,
|
||||
after_start=_collect_response, loop=loop)
|
||||
|
||||
if exceptions:
|
||||
raise ValueError("Exception during request: {}".format(exceptions))
|
||||
|
|
|
@ -3,7 +3,8 @@ from .exceptions import InvalidUsage
|
|||
|
||||
class MethodView:
|
||||
""" Simple class based implementation of view for the sanic.
|
||||
You should implement methods(get, post, put, patch, delete) for the class to every HTTP method you want to support.
|
||||
You should implement methods(get, post, put, patch, delete) for the class
|
||||
to every HTTP method you want to support.
|
||||
For example:
|
||||
class DummyView(View):
|
||||
|
||||
|
@ -30,4 +31,6 @@ class MethodView:
|
|||
handler = getattr(self, request.method.lower(), None)
|
||||
if handler:
|
||||
return handler(request, *args, **kwargs)
|
||||
raise InvalidUsage('Method {} not allowed for URL {}'.format(request.method, request.url), status_code=405)
|
||||
raise InvalidUsage(
|
||||
'Method {} not allowed for URL {}'.format(
|
||||
request.method, request.url), status_code=405)
|
||||
|
|
Loading…
Reference in New Issue
Block a user