diff options
author | Andy McCurdy <andy@andymccurdy.com> | 2019-05-26 17:11:07 -0700 |
---|---|---|
committer | Andy McCurdy <andy@andymccurdy.com> | 2019-05-26 17:11:07 -0700 |
commit | 00adde79dd058ca7086bc41563fad145800b6b9b (patch) | |
tree | 5c9f1caef374a97722475687a01df1e61c493e12 | |
parent | e6eff96a2da8ff187910747831de8785a191b5ab (diff) | |
download | redis-py-00adde79dd058ca7086bc41563fad145800b6b9b.tar.gz |
add tests for encoding issues and fix bugs found
-rwxr-xr-x | redis/client.py | 2 | ||||
-rw-r--r-- | tests/test_monitor.py | 17 |
2 files changed, 13 insertions, 6 deletions
diff --git a/redis/client.py b/redis/client.py index f024142..15ec190 100755 --- a/redis/client.py +++ b/redis/client.py @@ -2962,7 +2962,7 @@ class Monitor(object): m = self.monitor_re.match(command_data) db_id, client_address, client_port, command = m.groups() command = ' '.join(self.command_re.findall(command)) - command = command.replace('\\"', '"') + command = command.replace('\\"', '"').replace('\\\\', '\\') return { 'time': float(command_time), 'db': int(db_id), diff --git a/tests/test_monitor.py b/tests/test_monitor.py index 831f9d1..f46eeba 100644 --- a/tests/test_monitor.py +++ b/tests/test_monitor.py @@ -16,7 +16,13 @@ def wait_for_command(client, monitor, command): class TestPipeline(object): - def test_response_pieces(self, r): + def test_wait_command_not_found(self, r): + "Make sure the wait_for_command func works when command is not found" + with r.monitor() as m: + response = wait_for_command(r, m, 'nothing') + assert response is None + + def test_response_values(self, r): with r.monitor() as m: r.ping() response = wait_for_command(r, m, 'PING') @@ -32,8 +38,9 @@ class TestPipeline(object): response = wait_for_command(r, m, 'GET foo"bar') assert response['command'] == 'GET foo"bar' - def test_wait_command_not_found(self, r): - "Make sure the wait_for_command func works when command is not found" + def test_command_with_binary_data(self, r): with r.monitor() as m: - response = wait_for_command(r, m, 'nothing') - assert response is None + byte_string = b'foo\x92' + r.get(byte_string) + response = wait_for_command(r, m, 'GET foo\\x92') + assert response['command'] == 'GET foo\\x92' |