summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChayim <chayim@users.noreply.github.com>2021-07-15 08:57:41 +0300
committerGitHub <noreply@github.com>2021-07-15 08:57:41 +0300
commitcb97b9bdd47bf5a92f4efa88e52591344a08b98e (patch)
treedad22f0e2891fa44babf2e886ef845accab0f220
parentfc621bd1b4de35fa088f87895e5fa1ade6a9150c (diff)
downloadredis-py-cb97b9bdd47bf5a92f4efa88e52591344a08b98e.tar.gz
changing unit tests to account for defaults in redis flags (#1499)
Co-authored-by: Andy McCurdy <andy@andymccurdy.com>
-rw-r--r--tests/test_commands.py37
-rw-r--r--tests/test_pubsub.py4
-rw-r--r--tox.ini2
3 files changed, 23 insertions, 20 deletions
diff --git a/tests/test_commands.py b/tests/test_commands.py
index d1f85b7..2da4a89 100644
--- a/tests/test_commands.py
+++ b/tests/test_commands.py
@@ -108,25 +108,24 @@ class TestRedisCommands:
# test enabled=False
assert r.acl_setuser(username, enabled=False, reset=True)
- assert r.acl_getuser(username) == {
- 'categories': ['-@all'],
- 'commands': [],
- 'enabled': False,
- 'flags': ['off'],
- 'keys': [],
- 'passwords': [],
- }
+ acl = r.acl_getuser(username)
+ assert acl['categories'] == ['-@all']
+ assert acl['commands'] == []
+ assert acl['keys'] == []
+ assert acl['passwords'] == []
+ assert 'off' in acl['flags']
+ assert acl['enabled'] is False
# test nopass=True
assert r.acl_setuser(username, enabled=True, reset=True, nopass=True)
- assert r.acl_getuser(username) == {
- 'categories': ['-@all'],
- 'commands': [],
- 'enabled': True,
- 'flags': ['on', 'nopass'],
- 'keys': [],
- 'passwords': [],
- }
+ acl = r.acl_getuser(username)
+ assert acl['categories'] == ['-@all']
+ assert acl['commands'] == []
+ assert acl['keys'] == []
+ assert acl['passwords'] == []
+ assert 'on' in acl['flags']
+ assert 'nopass' in acl['flags']
+ assert acl['enabled'] is True
# test all args
assert r.acl_setuser(username, enabled=True, reset=True,
@@ -138,7 +137,7 @@ class TestRedisCommands:
assert set(acl['categories']) == set(['-@all', '+@set', '+@hash'])
assert set(acl['commands']) == set(['+get', '+mget', '-hset'])
assert acl['enabled'] is True
- assert acl['flags'] == ['on']
+ assert 'on' in acl['flags']
assert set(acl['keys']) == set([b'cache:*', b'objects:*'])
assert len(acl['passwords']) == 2
@@ -157,7 +156,7 @@ class TestRedisCommands:
assert set(acl['categories']) == set(['-@all', '+@set', '+@hash'])
assert set(acl['commands']) == set(['+get', '+mget'])
assert acl['enabled'] is True
- assert acl['flags'] == ['on']
+ assert 'on' in acl['flags']
assert set(acl['keys']) == set([b'cache:*', b'objects:*'])
assert len(acl['passwords']) == 2
@@ -196,7 +195,7 @@ class TestRedisCommands:
assert r.acl_setuser(username, enabled=False, reset=True)
users = r.acl_list()
- assert 'user %s off -@all' % username in users
+ assert len(users) == 2
@skip_if_server_version_lt(REDIS_6_VERSION)
def test_acl_log(self, r, request):
diff --git a/tests/test_pubsub.py b/tests/test_pubsub.py
index 17a1621..6a4f0aa 100644
--- a/tests/test_pubsub.py
+++ b/tests/test_pubsub.py
@@ -1,6 +1,7 @@
import threading
import time
from unittest import mock
+import platform
import pytest
import redis
@@ -547,6 +548,9 @@ class TestPubSubTimeouts:
class TestPubSubWorkerThread:
+
+ @pytest.mark.skipif(platform.python_implementation() == 'PyPy',
+ reason="Pypy threading issue")
def test_pubsub_worker_thread_exception_handler(self, r):
event = threading.Event()
diff --git a/tox.ini b/tox.ini
index 19f9aad..db7492d 100644
--- a/tox.ini
+++ b/tox.ini
@@ -3,7 +3,7 @@ addopts = -s
[tox]
minversion = 2.4
-envlist = {py35,py36,py37,py38,pypy3}-{plain,hiredis}, flake8, covreport, codecov
+envlist = {py35,py36,py37,py38,py39,pypy3}-{plain,hiredis}, flake8, covreport, codecov
[testenv]
deps =