* 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:
committed by
Stephen Sadowski
parent
aa7f2759a6
commit
d758f7c6df
@@ -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
|
||||
|
||||
@@ -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
|
||||
)
|
||||
|
||||
@@ -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('/')
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user