linteger fix and delete old tests

This commit is contained in:
Sergey Fedoruk 2019-01-02 01:35:25 +01:00 committed by Sergey Fedoruk
parent b7a6f36e95
commit 65daaaf64b
3 changed files with 22 additions and 40 deletions

View File

@ -5,12 +5,12 @@ import re
import typing
import warnings
from asyncio import CancelledError, ensure_future, get_event_loop, Protocol
from asyncio import CancelledError, Protocol, ensure_future, get_event_loop
from collections import defaultdict, deque
from functools import partial
from inspect import getmodulename, isawaitable, signature, stack
from socket import socket
from ssl import Purpose, create_default_context, SSLContext
from ssl import Purpose, SSLContext, create_default_context
from traceback import format_exc
from urllib.parse import urlencode, urlunparse
@ -969,17 +969,17 @@ class Sanic:
def run(
self,
host: typing.Optional[str]=None,
port: typing.Optional[int]=None,
debug: bool=False,
ssl: typing.Union[dict, SSLContext, None]=None,
sock: typing.Optional[socket]=None,
workers: int=1,
protocol: typing.Type[Protocol]=None,
backlog: int=100,
stop_event: typing.Any=None,
register_sys_signals: bool=True,
access_log: bool=None,
host: typing.Optional[str] = None,
port: typing.Optional[int] = None,
debug: bool = False,
ssl: typing.Union[dict, SSLContext, None] = None,
sock: typing.Optional[socket] = None,
workers: int = 1,
protocol: typing.Type[Protocol] = None,
backlog: int = 100,
stop_event: typing.Any = None,
register_sys_signals: bool = True,
access_log: typing.Optional[bool] = None,
**kwargs: typing.Any
) -> None:
"""Run the HTTP Server and listen until keyboard interrupt or term
@ -1003,7 +1003,8 @@ class Sanic:
:param backlog: a number of unaccepted connections that the system
will allow before refusing new connections
:type backlog: int
:param stop_event: event to be triggered before stopping the app - deprecated
:param stop_event: event to be triggered
before stopping the app - deprecated
:type stop_event: None
:param register_sys_signals: Register SIG* events
:type register_sys_signals: bool
@ -1043,12 +1044,7 @@ class Sanic:
)
# if access_log is passed explicitly change config.ACCESS_LOG
if access_log is not None:
if isinstance(access_log, bool):
self.config.ACCESS_LOG = access_log
else:
raise ServerError(
("'access_log' passed in 'run' should be boolean")
)
self.config.ACCESS_LOG = access_log
server_settings = self._helper(
host=host,
@ -1107,7 +1103,7 @@ class Sanic:
protocol: typing.Type[Protocol] = None,
backlog: int = 100,
stop_event: typing.Any = None,
access_log: bool = None,
access_log: typing.Optional[bool] = None,
) -> None:
"""
Asynchronous version of :func:`run`.
@ -1136,7 +1132,8 @@ class Sanic:
:param backlog: a number of unaccepted connections that the system
will allow before refusing new connections
:type backlog: int
:param stop_event: event to be triggered before stopping the app - deprecated
:param stop_event: event to be triggered
before stopping the app - deprecated
:type stop_event: None
:param access_log: Enables writing access logs (slows server)
:type access_log: bool
@ -1159,15 +1156,7 @@ class Sanic:
)
# if access_log is passed explicitly change config.ACCESS_LOG
if access_log is not None:
if isinstance(access_log, bool):
self.config.ACCESS_LOG = access_log
else:
raise ServerError(
(
"'access_log' passed in 'create_server' "
"should be boolean"
)
)
self.config.ACCESS_LOG = access_log
server_settings = self._helper(
host=host,

View File

@ -1,5 +1,6 @@
import os
import types
from distutils.util import strtobool
from sanic.exceptions import PyFileError

View File

@ -7,7 +7,7 @@ import pytest
from sanic import Sanic
from sanic.config import Config, DEFAULT_CONFIG
from sanic.exceptions import PyFileError, ServerError
from sanic.exceptions import PyFileError
@contextmanager
@ -223,10 +223,6 @@ def test_config_access_log_passing_in_run(app):
app.run(port=1340, access_log=True)
assert app.config.ACCESS_LOG == True
with pytest.raises(ServerError) as e:
app.run(port=1340, access_log='string')
assert str(e.value) == ("'access_log' passed in 'run' should be boolean")
async def test_config_access_log_passing_in_create_server(app):
assert app.config.ACCESS_LOG == True
@ -241,10 +237,6 @@ async def test_config_access_log_passing_in_create_server(app):
await app.create_server(port=1342, access_log=True)
assert app.config.ACCESS_LOG == True
with pytest.raises(ServerError) as e:
await app.create_server(port=1343, access_log='somestring')
assert str(e.value) == ("'access_log' passed in 'create_server' should be boolean")
def test_config_rewrite_keep_alive():
config = Config()