GIT1505: Backport changes from #1502 to 18.12LTS (#1507)

* GIT1505: backport changes from #1502 to 18.12LTS

* GIT1505: fix pytest version to address UT failures

* fix: GIT1505: fix unittests with caplog and some other warnings

Signed-off-by: Harsha Narayana <harsha2k4@gmail.com>
This commit is contained in:
Harsha Narayana
2019-03-06 20:06:03 +05:30
committed by Stephen Sadowski
parent aa7f2759a6
commit d758f7c6df
8 changed files with 17 additions and 17 deletions

View File

@@ -138,6 +138,7 @@ def test_handle_request_with_nested_sanic_exception(app, monkeypatch, caplog):
raise Exception
return text('OK')
caplog.set_level(logging.ERROR, logger="sanic.root")
with caplog.at_level(logging.ERROR):
request, response = app.test_client.get('/')
assert response.status == 500

View File

@@ -141,7 +141,7 @@ class ReuseableSanicTestClient(SanicTestClient):
conn = self._tcp_connector
else:
conn = ReuseableTCPConnector(
verify_ssl=False,
ssl=False,
loop=self._loop,
keepalive_timeout=request_keepalive
)

View File

@@ -81,6 +81,7 @@ def test_middleware_response_raise_cancelled_error(app, caplog):
def handler(request):
return text('OK')
caplog.set_level(logging.ERROR, logger="sanic.root")
with caplog.at_level(logging.ERROR):
reqrequest, response = app.test_client.get('/')
@@ -98,6 +99,7 @@ def test_middleware_response_raise_exception(app, caplog):
async def process_response(request, response):
raise Exception('Exception at response middleware')
caplog.set_level(logging.ERROR, logger="sanic.root")
with caplog.at_level(logging.ERROR):
reqrequest, response = app.test_client.get('/')

View File

@@ -149,7 +149,7 @@ class DelayableSanicTestClient(SanicTestClient):
url = 'http://{host}:{port}{uri}'.format(
host=HOST, port=self.port, uri=uri)
conn = DelayableTCPConnector(pre_request_delay=self._request_delay,
verify_ssl=False, loop=self._loop)
ssl=False, loop=self._loop)
async with aiohttp.ClientSession(cookies=cookies, connector=conn,
loop=self._loop) as session:
# Insert a delay after creating the connection

View File

@@ -155,8 +155,8 @@ def test_fails_with_int_message(app):
app.url_for('fail', **failing_kwargs)
expected_error = (
'Value "not_int" for parameter `foo` '
'does not match pattern for type `int`: \d+')
r'Value "not_int" for parameter `foo` '
r'does not match pattern for type `int`: \d+')
assert str(e.value) == expected_error