Skip to content

Commit 70466b2

Browse files
committed
tests against decoders directly
1 parent e18283a commit 70466b2

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

redis/commands/json/decoders.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ def decode_list(b):
5353
if isinstance(b, list):
5454
return [nativestr(obj) for obj in b]
5555
elif isinstance(b, bytes):
56-
return nativestr(b)
56+
return unstring(nativestr(b))
5757
elif isinstance(b, str):
5858
return unstring(b)
5959
return b

tests/test_json.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import redis
33
from redis.commands.json.path import Path
44
from redis import exceptions
5+
from redis.commands.json.decoders import unstring, decode_list
56
from .conftest import skip_ifmodversion_lt
67

78

@@ -1374,3 +1375,13 @@ def test_arrindex_dollar(client):
13741375
"test_None",
13751376
"..nested2_not_found.arr",
13761377
"None") == 0
1378+
1379+
1380+
def test_decoders_and_unstring():
1381+
assert unstring("4") == 4
1382+
assert unstring("45.55") == 45.55
1383+
assert unstring("hello world") == "hello world"
1384+
1385+
assert decode_list(b"45.55") == 45.55
1386+
assert decode_list("45.55") == 45.55
1387+
assert decode_list(['hello', b'world']) == ['hello', 'world']

0 commit comments

Comments
 (0)