fix access_log in run server and fix bool in env variables

This commit is contained in:
Sergey Fedoruk
2018-12-30 19:37:30 +01:00
committed by Sergey Fedoruk
parent d76d5e2c5f
commit 391fcdc83d
10 changed files with 143 additions and 78 deletions

View File

@@ -3,13 +3,17 @@ from sanic import Sanic
import asyncio
from asyncio import sleep as aio_sleep
from sanic.response import text
from sanic.config import Config
from sanic import server
import aiohttp
from aiohttp import TCPConnector
from sanic.testing import SanicTestClient, HOST, PORT
CONFIG_FOR_TESTS = {
"KEEP_ALIVE_TIMEOUT": 2,
"KEEP_ALIVE": True
}
class ReuseableTCPConnector(TCPConnector):
def __init__(self, *args, **kwargs):
super(ReuseableTCPConnector, self).__init__(*args, **kwargs)
@@ -141,7 +145,7 @@ class ReuseableSanicTestClient(SanicTestClient):
# loop, so the changes above are required too.
async def _local_request(self, method, uri, cookies=None, *args, **kwargs):
request_keepalive = kwargs.pop(
"request_keepalive", Config.KEEP_ALIVE_TIMEOUT
"request_keepalive", CONFIG_FOR_TESTS['KEEP_ALIVE_TIMEOUT']
)
if uri.startswith(("http:", "https:", "ftp:", "ftps://" "//")):
url = uri
@@ -191,12 +195,14 @@ class ReuseableSanicTestClient(SanicTestClient):
return response
Config.KEEP_ALIVE_TIMEOUT = 2
Config.KEEP_ALIVE = True
keep_alive_timeout_app_reuse = Sanic("test_ka_timeout_reuse")
keep_alive_app_client_timeout = Sanic("test_ka_client_timeout")
keep_alive_app_server_timeout = Sanic("test_ka_server_timeout")
keep_alive_timeout_app_reuse.config.update(CONFIG_FOR_TESTS)
keep_alive_app_client_timeout.config.update(CONFIG_FOR_TESTS)
keep_alive_app_server_timeout.config.update(CONFIG_FOR_TESTS)
@keep_alive_timeout_app_reuse.route("/1")
async def handler1(request):