summaryrefslogtreecommitdiff
path: root/tests/test_asyncio/test_connection.py
diff options
context:
space:
mode:
authorKristján Valur Jónsson <sweskman@gmail.com>2022-07-26 12:25:23 +0000
committerGitHub <noreply@github.com>2022-07-26 15:25:23 +0300
commit6f208212ed9114921840404591aecca9acd38f08 (patch)
treeab37049c4d6b5c04a11b32c85218d50bd8d54d52 /tests/test_asyncio/test_connection.py
parent1df1d32bb6845d2ccbbc340199babe9fe0ef29d6 (diff)
downloadredis-py-6f208212ed9114921840404591aecca9acd38f08.tar.gz
Fix warnings and resource usage problems in asyncio unittests (#2258)
* Use pytest-asyncio in auto mode Remove overly genereric `pytestmark=pytest.mark.asyncio` causing lots of warning noise * Use "Factories as Fixtures" test pattern for the `create_redis` fixture this fixture is now async, avoiding teardown problems with missing event loops. * Fix sporadic error on fast event loops, such as `--uvloop` * Close connection, even if "username" was in kwargs This fixes a resource usage warning in the async unittests. * Do async cleanup of acl passwords via a fixture * Remove unused import, fix whitespace * Fix test with missing "await" * Close pubsub objects after use in unittest Use a simple fixture where possible, otherwise manually call pubsub.close() * re-introduce `pytestmark=pytest.mark.asyncio` for python 3.6 * Use context manager to clean up connections in connection pool for unit tests * Provide asynccontextmanager for python 3.6 * make `test_late_subscribe()` more robuste * Catch a couple of additional leaked resources
Diffstat (limited to 'tests/test_asyncio/test_connection.py')
-rw-r--r--tests/test_asyncio/test_connection.py4
1 files changed, 3 insertions, 1 deletions
diff --git a/tests/test_asyncio/test_connection.py b/tests/test_asyncio/test_connection.py
index 78a3efd..8030f7e 100644
--- a/tests/test_asyncio/test_connection.py
+++ b/tests/test_asyncio/test_connection.py
@@ -1,5 +1,6 @@
import asyncio
import socket
+import sys
import types
from unittest.mock import patch
@@ -18,7 +19,8 @@ from tests.conftest import skip_if_server_version_lt
from .compat import mock
-pytestmark = pytest.mark.asyncio
+if sys.version_info[0:2] == (3, 6):
+ pytestmark = pytest.mark.asyncio
@pytest.mark.onlynoncluster