Skip to content
This repository has been archived by the owner on Feb 21, 2023. It is now read-only.

Commit

Permalink
fix time command when connection-wide encoding is set (fixes #266)
Browse files Browse the repository at this point in the history
  • Loading branch information
popravich committed Oct 25, 2017
1 parent 4b2d4ec commit 3e01ab4
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion aioredis/commands/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ def _split(s):


def to_time(obj):
return float(obj[0] + b'.' + obj[1].zfill(6))
return int(obj[0]) + int(obj[1]) * 1e-6


def to_tuples(value):
Expand Down
9 changes: 9 additions & 0 deletions tests/server_commands_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,15 @@ def test_time(redis):
pytest.assert_almost_equal(int(res), int(time.time()), delta=10)


@pytest.mark.run_loop
def test_time_with_encoding(create_redis, server, loop):
redis = yield from create_redis(server.tcp_address, loop=loop,
encoding='utf-8')
res = yield from redis.time()
assert isinstance(res, float)
pytest.assert_almost_equal(int(res), int(time.time()), delta=10)


@pytest.mark.run_loop
def test_slowlog_len(redis):
res = yield from redis.slowlog_len()
Expand Down

0 comments on commit 3e01ab4

Please sign in to comment.