diff --git a/tests/test_commands.py b/tests/test_commands.py index d74a948e..122f6631 100644 --- a/tests/test_commands.py +++ b/tests/test_commands.py @@ -865,9 +865,9 @@ def test_object(self, r): def test_ping(self, r): assert r.ping() assert r.ping(0) - assert r.ping("Valkey") - assert r.ping(" Valkey ") - assert r.ping("Valkey", test="a") + assert r.ping("valkey") + assert r.ping(" hello ") + assert r.ping("abc", test="a") @pytest.mark.onlynoncluster def test_quit(self, r): diff --git a/valkey/_parsers/helpers.py b/valkey/_parsers/helpers.py index c8f31f92..d21e036b 100644 --- a/valkey/_parsers/helpers.py +++ b/valkey/_parsers/helpers.py @@ -1,6 +1,9 @@ import datetime -from valkey.utils import str_if_bytes, safe_str +from valkey.utils import ( + safe_str, + str_if_bytes, +) def timestamp_to_datetime(response): @@ -686,7 +689,7 @@ def parse_set_result(response, **options): def parse_ping(response, **options): response = str_if_bytes(response) - message = "PONG" if options.get("message") is None else options.get("message") + message = options.get("message", "PONG") return response == safe_str(message) diff --git a/valkey/commands/core.py b/valkey/commands/core.py index 84eaa2b7..0542a91b 100644 --- a/valkey/commands/core.py +++ b/valkey/commands/core.py @@ -1210,7 +1210,9 @@ def ping(self, message=None, **kwargs) -> ResponseT: For more information see https://valkey.io/commands/ping """ args = ["PING", message] if message is not None else ["PING"] - return self.execute_command(*args, message=message, **kwargs) + if message is not None: + kwargs["message"] = message + return self.execute_command(*args, **kwargs) def quit(self, **kwargs) -> ResponseT: """