From 8dd8e9916e773423d32fd4130736d552e46c2e17 Mon Sep 17 00:00:00 2001 From: 7 Date: Tue, 8 Jan 2019 07:15:23 -0800 Subject: [PATCH] upgrade pytest version that compatible with pytest-cov, fixes some caplog unit tests (#1464) --- setup.py | 2 +- tests/test_app.py | 4 ++-- tests/test_keep_alive_timeout.py | 2 +- tests/test_middleware.py | 20 ++++++++++---------- tests/test_request_timeout.py | 2 +- tox.ini | 2 +- 6 files changed, 16 insertions(+), 16 deletions(-) diff --git a/setup.py b/setup.py index 5e8933e5..05d13637 100644 --- a/setup.py +++ b/setup.py @@ -86,7 +86,7 @@ requirements = [ ] tests_require = [ - "pytest==3.3.2", + "pytest==4.1.0", "multidict>=4.0,<5.0", "gunicorn", "pytest-cov", diff --git a/tests/test_app.py b/tests/test_app.py index dbe5b9d9..be2a45da 100644 --- a/tests/test_app.py +++ b/tests/test_app.py @@ -155,8 +155,8 @@ def test_handle_request_with_nested_sanic_exception(app, monkeypatch, caplog): request, response = app.test_client.get("/") assert response.status == 500 assert response.text == "Error: Mock SanicException" - assert caplog.record_tuples[0] == ( + assert ( "sanic.root", logging.ERROR, "Exception occurred while handling uri: 'http://127.0.0.1:42101/'", - ) + ) in caplog.record_tuples diff --git a/tests/test_keep_alive_timeout.py b/tests/test_keep_alive_timeout.py index cef5da5b..6893f652 100644 --- a/tests/test_keep_alive_timeout.py +++ b/tests/test_keep_alive_timeout.py @@ -161,7 +161,7 @@ class ReuseableSanicTestClient(SanicTestClient): conn = self._tcp_connector else: conn = ReuseableTCPConnector( - verify_ssl=False, + ssl=False, loop=self._loop, keepalive_timeout=request_keepalive, ) diff --git a/tests/test_middleware.py b/tests/test_middleware.py index a65da8ae..6e94b5c8 100644 --- a/tests/test_middleware.py +++ b/tests/test_middleware.py @@ -86,12 +86,12 @@ def test_middleware_response_raise_cancelled_error(app, caplog): with caplog.at_level(logging.ERROR): reqrequest, response = app.test_client.get("/") - assert response.status == 503 - assert caplog.record_tuples[0] == ( - "sanic.root", - logging.ERROR, - "Exception occurred while handling uri: 'http://127.0.0.1:42101/'", - ) + assert response.status == 503 + assert ( + "sanic.root", + logging.ERROR, + "Exception occurred while handling uri: 'http://127.0.0.1:42101/'", + ) in caplog.record_tuples def test_middleware_response_raise_exception(app, caplog): @@ -103,16 +103,16 @@ def test_middleware_response_raise_exception(app, caplog): reqrequest, response = app.test_client.get("/") assert response.status == 404 - assert caplog.record_tuples[0] == ( + assert ( "sanic.root", logging.ERROR, "Exception occurred while handling uri: 'http://127.0.0.1:42101/'", - ) - assert caplog.record_tuples[1] == ( + ) in caplog.record_tuples + assert ( "sanic.error", logging.ERROR, "Exception occurred in one of response middleware handlers", - ) + ) in caplog.record_tuples def test_middleware_override_request(app): diff --git a/tests/test_request_timeout.py b/tests/test_request_timeout.py index 8a060a74..f3460ed2 100644 --- a/tests/test_request_timeout.py +++ b/tests/test_request_timeout.py @@ -152,7 +152,7 @@ class DelayableSanicTestClient(SanicTestClient): ) conn = DelayableTCPConnector( pre_request_delay=self._request_delay, - verify_ssl=False, + ssl=False, loop=self._loop, ) async with aiohttp.ClientSession( diff --git a/tox.ini b/tox.ini index 4d3ca623..503d8aa5 100644 --- a/tox.ini +++ b/tox.ini @@ -8,7 +8,7 @@ setenv = {py35,py36,py37}-no-ext: SANIC_NO_UVLOOP=1 deps = coverage - pytest==3.3.2 + pytest==4.1.0 pytest-cov pytest-sanic pytest-sugar