From 7c023d24b3fb3f0610e960d7d177ec0694bd4004 Mon Sep 17 00:00:00 2001 From: Jon Dufresne Date: Wed, 12 Feb 2020 14:01:42 -0800 Subject: Enable warnings during tests and fix discovered cases (#1283) Helps identify problematic or buggy code. When a warning is displayed, it should be analyzed and fixed. The r and r2 fixture now close the client after the test is complete. --- tests/conftest.py | 6 ++++-- tox.ini | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/tests/conftest.py b/tests/conftest.py index 87e6301..0007b84 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -74,13 +74,15 @@ def _get_client(cls, request, single_connection_client=True, **kwargs): @pytest.fixture() def r(request): - return _get_client(redis.Redis, request) + with _get_client(redis.Redis, request) as client: + yield client @pytest.fixture() def r2(request): "A second client for tests that need multiple" - return _get_client(redis.Redis, request) + with _get_client(redis.Redis, request) as client: + yield client def _gen_cluster_mock_resp(r, response): diff --git a/tox.ini b/tox.ini index 77db932..2d6e60a 100644 --- a/tox.ini +++ b/tox.ini @@ -9,7 +9,7 @@ deps = pytest >= 2.7.0 extras = hiredis: hiredis -commands = {envpython} -m coverage run -m pytest {posargs} +commands = {envpython} -m coverage run -m pytest -W always {posargs} [testenv:pycodestyle] basepython = python3.6 -- cgit v1.2.1