diff options
author | Anas <anas.el.amraoui@live.com> | 2021-11-30 18:05:51 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-11-30 18:05:51 +0200 |
commit | b94e230b17d08e6c89d134e933c706256b79bc4a (patch) | |
tree | 993bd7565169229326b810b66939587431ab9dc6 /tests/test_helpers.py | |
parent | 368a25f9d163d784a8896f1c087582405e98e006 (diff) | |
download | redis-py-b94e230b17d08e6c89d134e933c706256b79bc4a.tar.gz |
Added black and isort (#1734)
Diffstat (limited to 'tests/test_helpers.py')
-rw-r--r-- | tests/test_helpers.py | 59 |
1 files changed, 34 insertions, 25 deletions
diff --git a/tests/test_helpers.py b/tests/test_helpers.py index 402eccf..3595829 100644 --- a/tests/test_helpers.py +++ b/tests/test_helpers.py @@ -1,19 +1,20 @@ import string + from redis.commands.helpers import ( delist, list_or_args, nativestr, + parse_to_dict, parse_to_list, quote_string, random_string, - parse_to_dict ) def test_list_or_args(): k = ["hello, world"] a = ["some", "argument", "list"] - assert list_or_args(k, a) == k+a + assert list_or_args(k, a) == k + a for i in ["banana", b"banana"]: assert list_or_args(i, a) == [i] + a @@ -22,42 +23,50 @@ def test_list_or_args(): def test_parse_to_list(): assert parse_to_list(None) == [] r = ["hello", b"my name", "45", "555.55", "is simon!", None] - assert parse_to_list(r) == \ - ["hello", "my name", 45, 555.55, "is simon!", None] + assert parse_to_list(r) == ["hello", "my name", 45, 555.55, "is simon!", None] def test_parse_to_dict(): assert parse_to_dict(None) == {} - r = [['Some number', '1.0345'], - ['Some string', 'hello'], - ['Child iterators', - ['Time', '0.2089', 'Counter', 3, 'Child iterators', - ['Type', 'bar', 'Time', '0.0729', 'Counter', 3], - ['Type', 'barbar', 'Time', '0.058', 'Counter', 3]]]] + r = [ + ["Some number", "1.0345"], + ["Some string", "hello"], + [ + "Child iterators", + [ + "Time", + "0.2089", + "Counter", + 3, + "Child iterators", + ["Type", "bar", "Time", "0.0729", "Counter", 3], + ["Type", "barbar", "Time", "0.058", "Counter", 3], + ], + ], + ] assert parse_to_dict(r) == { - 'Child iterators': { - 'Child iterators': [ - {'Counter': 3.0, 'Time': 0.0729, 'Type': 'bar'}, - {'Counter': 3.0, 'Time': 0.058, 'Type': 'barbar'} + "Child iterators": { + "Child iterators": [ + {"Counter": 3.0, "Time": 0.0729, "Type": "bar"}, + {"Counter": 3.0, "Time": 0.058, "Type": "barbar"}, ], - 'Counter': 3.0, - 'Time': 0.2089 + "Counter": 3.0, + "Time": 0.2089, }, - 'Some number': 1.0345, - 'Some string': 'hello' + "Some number": 1.0345, + "Some string": "hello", } def test_nativestr(): - assert nativestr('teststr') == 'teststr' - assert nativestr(b'teststr') == 'teststr' - assert nativestr('null') is None + assert nativestr("teststr") == "teststr" + assert nativestr(b"teststr") == "teststr" + assert nativestr("null") is None def test_delist(): assert delist(None) is None - assert delist([b'hello', 'world', b'banana']) == \ - ['hello', 'world', 'banana'] + assert delist([b"hello", "world", b"banana"]) == ["hello", "world", "banana"] def test_random_string(): @@ -69,5 +78,5 @@ def test_random_string(): def test_quote_string(): assert quote_string("hello world!") == '"hello world!"' - assert quote_string('') == '""' - assert quote_string('hello world!') == '"hello world!"' + assert quote_string("") == '""' + assert quote_string("hello world!") == '"hello world!"' |