pep8 fixes

This commit is contained in:
Anton Zhyrney 2016-11-25 09:29:25 +02:00
parent fca0221d91
commit c3c7964e2e
3 changed files with 12 additions and 5 deletions

View File

@ -62,7 +62,9 @@ class Sanic:
def add_route(self, handler, uri, methods=None): 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 handler: function or class instance
:param uri: path of the URL :param uri: path of the URL
:param methods: list or tuple of methods allowed :param methods: list or tuple of methods allowed

View File

@ -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, 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 = [] results = []
exceptions = [] exceptions = []
@ -34,7 +35,8 @@ def sanic_endpoint_test(app, method='get', uri='/', gather_request=True,
exceptions.append(e) exceptions.append(e)
app.stop() 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: if exceptions:
raise ValueError("Exception during request: {}".format(exceptions)) raise ValueError("Exception during request: {}".format(exceptions))

View File

@ -3,7 +3,8 @@ from .exceptions import InvalidUsage
class MethodView: class MethodView:
""" Simple class based implementation of view for the sanic. """ 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: For example:
class DummyView(View): class DummyView(View):
@ -30,4 +31,6 @@ class MethodView:
handler = getattr(self, request.method.lower(), None) handler = getattr(self, request.method.lower(), None)
if handler: if handler:
return handler(request, *args, **kwargs) 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)