default to auto_reload in debug mode (#1159)

* default to auto_reload in debug mode

* disable auto-reload in testing client
This commit is contained in:
Raphael Deem 2018-04-01 20:52:56 -07:00 committed by GitHub
parent 6cf320bedb
commit 8f2d543d9f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 2 deletions

View File

@ -649,7 +649,7 @@ class Sanic:
def run(self, host=None, port=None, debug=False, ssl=None,
sock=None, workers=1, protocol=None,
backlog=100, stop_event=None, register_sys_signals=True,
access_log=True, auto_reload=False):
access_log=True, **kwargs):
"""Run the HTTP Server and listen until keyboard interrupt or term
signal. On termination, drain connections before closing.
@ -667,6 +667,13 @@ class Sanic:
:param protocol: Subclass of asyncio protocol class
:return: Nothing
"""
# Default auto_reload to false
auto_reload = False
# If debug is set, default it to true
if debug:
auto_reload = True
# Allow for overriding either of the defaults
auto_reload = kwargs.get("auto_reload", auto_reload)
if sock is None:
host, port = host or "127.0.0.1", port or 8000

View File

@ -45,7 +45,7 @@ class SanicTestClient:
def _sanic_endpoint_test(
self, method='get', uri='/', gather_request=True,
debug=False, server_kwargs={},
debug=False, server_kwargs={"auto_reload": False},
*request_args, **request_kwargs):
results = [None, None]
exceptions = []