Skip to content

Commit 20f3851

Browse files
committed
Codestyle changes
1 parent 97abacd commit 20f3851

File tree

2 files changed

+69
-68
lines changed

2 files changed

+69
-68
lines changed

redis/connection.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,10 @@
4242
HIREDIS_PACK_AVAILABLE,
4343
SSL_AVAILABLE,
4444
compare_versions,
45+
ensure_string,
4546
format_error_message,
4647
get_lib_version,
47-
str_if_bytes, ensure_string,
48+
str_if_bytes,
4849
)
4950

5051
if HIREDIS_AVAILABLE:

tests/test_cache.py

Lines changed: 67 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -72,19 +72,19 @@ def test_get_from_given_cache(self, r, r2):
7272
# get key from redis and save in local cache
7373
assert r.get("foo") in [b"bar", "bar"]
7474
# get key from local cache
75-
assert (
76-
cache.get(CacheKey(command="GET", redis_keys=("foo",))).cache_value
77-
in [b"bar", "bar"]
78-
)
75+
assert cache.get(CacheKey(command="GET", redis_keys=("foo",))).cache_value in [
76+
b"bar",
77+
"bar",
78+
]
7979
# change key in redis (cause invalidation)
8080
r2.set("foo", "barbar")
8181
# Retrieves a new value from server and cache it
8282
assert r.get("foo") in [b"barbar", "barbar"]
8383
# Make sure that new value was cached
84-
assert (
85-
cache.get(CacheKey(command="GET", redis_keys=("foo",))).cache_value
86-
in [b"barbar", "barbar"]
87-
)
84+
assert cache.get(CacheKey(command="GET", redis_keys=("foo",))).cache_value in [
85+
b"barbar",
86+
"barbar",
87+
]
8888

8989
@pytest.mark.parametrize(
9090
"r",
@@ -117,19 +117,19 @@ def test_get_from_default_cache(self, r, r2):
117117
# get key from redis and save in local cache
118118
assert r.get("foo") in [b"bar", "bar"]
119119
# get key from local cache
120-
assert (
121-
cache.get(CacheKey(command="GET", redis_keys=("foo",))).cache_value
122-
in [b"bar", "bar"]
123-
)
120+
assert cache.get(CacheKey(command="GET", redis_keys=("foo",))).cache_value in [
121+
b"bar",
122+
"bar",
123+
]
124124
# change key in redis (cause invalidation)
125125
r2.set("foo", "barbar")
126126
# Retrieves a new value from server and cache it
127127
assert r.get("foo") in [b"barbar", "barbar"]
128128
# Make sure that new value was cached
129-
assert (
130-
cache.get(CacheKey(command="GET", redis_keys=("foo",))).cache_value
131-
in [b"barbar", "barbar"]
132-
)
129+
assert cache.get(CacheKey(command="GET", redis_keys=("foo",))).cache_value in [
130+
b"barbar",
131+
"barbar",
132+
]
133133

134134
@pytest.mark.parametrize(
135135
"r",
@@ -379,19 +379,19 @@ def test_get_from_cache(self, r):
379379
# get key from redis and save in local cache
380380
assert r.get("foo") in [b"bar", "bar"]
381381
# get key from local cache
382-
assert (
383-
cache.get(CacheKey(command="GET", redis_keys=("foo",))).cache_value
384-
in [b"bar", "bar"]
385-
)
382+
assert cache.get(CacheKey(command="GET", redis_keys=("foo",))).cache_value in [
383+
b"bar",
384+
"bar",
385+
]
386386
# change key in redis (cause invalidation)
387387
r.set("foo", "barbar")
388388
# Retrieves a new value from server and cache it
389389
assert r.get("foo") in [b"barbar", "barbar"]
390390
# Make sure that new value was cached
391-
assert (
392-
cache.get(CacheKey(command="GET", redis_keys=("foo",))).cache_value
393-
in [b"barbar", "barbar"]
394-
)
391+
assert cache.get(CacheKey(command="GET", redis_keys=("foo",))).cache_value in [
392+
b"barbar",
393+
"barbar",
394+
]
395395
# Make sure that cache is shared between nodes.
396396
assert (
397397
cache == r.nodes_manager.get_node_from_slot(1).redis_connection.get_cache()
@@ -420,19 +420,19 @@ def test_get_from_custom_cache(self, r, r2):
420420
# get key from redis and save in local cache
421421
assert r.get("foo") in [b"bar", "bar"]
422422
# get key from local cache
423-
assert (
424-
cache.get(CacheKey(command="GET", redis_keys=("foo",))).cache_value
425-
in [b"bar", "bar"]
426-
)
423+
assert cache.get(CacheKey(command="GET", redis_keys=("foo",))).cache_value in [
424+
b"bar",
425+
"bar",
426+
]
427427
# change key in redis (cause invalidation)
428428
r2.set("foo", "barbar")
429429
# Retrieves a new value from server and cache it
430430
assert r.get("foo") in [b"barbar", "barbar"]
431431
# Make sure that new value was cached
432-
assert (
433-
cache.get(CacheKey(command="GET", redis_keys=("foo",))).cache_value
434-
in [b"barbar", "barbar"]
435-
)
432+
assert cache.get(CacheKey(command="GET", redis_keys=("foo",))).cache_value in [
433+
b"barbar",
434+
"barbar",
435+
]
436436

437437
@pytest.mark.parametrize(
438438
"r",
@@ -640,7 +640,7 @@ class TestSentinelCache:
640640
"cache": DefaultCache(CacheConfig(max_size=128)),
641641
"force_master_ip": "localhost",
642642
"decode_responses": True,
643-
}
643+
},
644644
],
645645
indirect=True,
646646
)
@@ -651,19 +651,19 @@ def test_get_from_cache(self, master):
651651
# get key from redis and save in local cache_data
652652
assert master.get("foo") in [b"bar", "bar"]
653653
# get key from local cache_data
654-
assert (
655-
cache.get(CacheKey(command="GET", redis_keys=("foo",))).cache_value
656-
in [b"bar", "bar"]
657-
)
654+
assert cache.get(CacheKey(command="GET", redis_keys=("foo",))).cache_value in [
655+
b"bar",
656+
"bar",
657+
]
658658
# change key in redis (cause invalidation)
659659
master.set("foo", "barbar")
660660
# get key from redis
661661
assert master.get("foo") in [b"barbar", "barbar"]
662662
# Make sure that new value was cached
663-
assert (
664-
cache.get(CacheKey(command="GET", redis_keys=("foo",))).cache_value
665-
in [b"barbar", "barbar"]
666-
)
663+
assert cache.get(CacheKey(command="GET", redis_keys=("foo",))).cache_value in [
664+
b"barbar",
665+
"barbar",
666+
]
667667

668668
@pytest.mark.parametrize(
669669
"r",
@@ -687,19 +687,19 @@ def test_get_from_default_cache(self, r, r2):
687687
# get key from redis and save in local cache_data
688688
assert r.get("foo") in [b"bar", "bar"]
689689
# get key from local cache_data
690-
assert (
691-
cache.get(CacheKey(command="GET", redis_keys=("foo",))).cache_value
692-
in [b"bar", "bar"]
693-
)
690+
assert cache.get(CacheKey(command="GET", redis_keys=("foo",))).cache_value in [
691+
b"bar",
692+
"bar",
693+
]
694694
# change key in redis (cause invalidation)
695695
r2.set("foo", "barbar")
696696
# Retrieves a new value from server and cache_data it
697697
assert r.get("foo") in [b"barbar", "barbar"]
698698
# Make sure that new value was cached
699-
assert (
700-
cache.get(CacheKey(command="GET", redis_keys=("foo",))).cache_value
701-
in [b"barbar", "barbar"]
702-
)
699+
assert cache.get(CacheKey(command="GET", redis_keys=("foo",))).cache_value in [
700+
b"barbar",
701+
"barbar",
702+
]
703703

704704
@pytest.mark.parametrize(
705705
"sentinel_setup",
@@ -760,7 +760,7 @@ def test_cache_clears_on_disconnect(self, master, cache):
760760

761761
@pytest.mark.skipif(HIREDIS_AVAILABLE, reason="PythonParser only")
762762
@pytest.mark.onlynoncluster
763-
#@skip_if_resp_version(2)
763+
# @skip_if_resp_version(2)
764764
@skip_if_server_version_lt("7.4.0")
765765
class TestSSLCache:
766766
@pytest.mark.parametrize(
@@ -774,7 +774,7 @@ class TestSSLCache:
774774
"cache": DefaultCache(CacheConfig(max_size=128)),
775775
"ssl": True,
776776
"decode_responses": True,
777-
}
777+
},
778778
],
779779
indirect=True,
780780
)
@@ -786,10 +786,10 @@ def test_get_from_cache(self, r, r2, cache):
786786
# get key from redis and save in local cache_data
787787
assert r.get("foo") in [b"bar", "bar"]
788788
# get key from local cache_data
789-
assert (
790-
cache.get(CacheKey(command="GET", redis_keys=("foo",))).cache_value
791-
in [b"bar", "bar"]
792-
)
789+
assert cache.get(CacheKey(command="GET", redis_keys=("foo",))).cache_value in [
790+
b"bar",
791+
"bar",
792+
]
793793
# change key in redis (cause invalidation)
794794
assert r2.set("foo", "barbar")
795795
# Timeout needed for SSL connection because there's timeout
@@ -798,10 +798,10 @@ def test_get_from_cache(self, r, r2, cache):
798798
# Retrieves a new value from server and cache_data it
799799
assert r.get("foo") in [b"barbar", "barbar"]
800800
# Make sure that new value was cached
801-
assert (
802-
cache.get(CacheKey(command="GET", redis_keys=("foo",))).cache_value
803-
in [b"barbar", "barbar"]
804-
)
801+
assert cache.get(CacheKey(command="GET", redis_keys=("foo",))).cache_value in [
802+
b"barbar",
803+
"barbar",
804+
]
805805

806806
@pytest.mark.parametrize(
807807
"r",
@@ -827,10 +827,10 @@ def test_get_from_custom_cache(self, r, r2):
827827
# get key from redis and save in local cache_data
828828
assert r.get("foo") in [b"bar", "bar"]
829829
# get key from local cache_data
830-
assert (
831-
cache.get(CacheKey(command="GET", redis_keys=("foo",))).cache_value
832-
in [b"bar", "bar"]
833-
)
830+
assert cache.get(CacheKey(command="GET", redis_keys=("foo",))).cache_value in [
831+
b"bar",
832+
"bar",
833+
]
834834
# change key in redis (cause invalidation)
835835
r2.set("foo", "barbar")
836836
# Timeout needed for SSL connection because there's timeout
@@ -839,10 +839,10 @@ def test_get_from_custom_cache(self, r, r2):
839839
# Retrieves a new value from server and cache_data it
840840
assert r.get("foo") in [b"barbar", "barbar"]
841841
# Make sure that new value was cached
842-
assert (
843-
cache.get(CacheKey(command="GET", redis_keys=("foo",))).cache_value
844-
in [b"barbar", "barbar"]
845-
)
842+
assert cache.get(CacheKey(command="GET", redis_keys=("foo",))).cache_value in [
843+
b"barbar",
844+
"barbar",
845+
]
846846

847847
@pytest.mark.parametrize(
848848
"r",

0 commit comments

Comments
 (0)