11import asyncio
2+ import math
23from datetime import datetime , timedelta
34
45from tests .conftest import skip_if_server_version_lt
@@ -128,9 +129,9 @@ async def test_hpexpire_multiple_fields(r):
128129async def test_hexpireat_basic (r ):
129130 await r .delete ("test:hash" )
130131 await r .hset ("test:hash" , mapping = {"field1" : "value1" , "field2" : "value2" })
131- exp_time = int ((datetime .now () + timedelta (seconds = 1 )).timestamp ())
132+ exp_time = math . ceil ((datetime .now () + timedelta (seconds = 1 )).timestamp ())
132133 assert await r .hexpireat ("test:hash" , exp_time , "field1" ) == [1 ]
133- await asyncio .sleep (1 .1 )
134+ await asyncio .sleep (2 .1 )
134135 assert await r .hexists ("test:hash" , "field1" ) is False
135136 assert await r .hexists ("test:hash" , "field2" ) is True
136137
@@ -139,9 +140,9 @@ async def test_hexpireat_basic(r):
139140async def test_hexpireat_with_datetime (r ):
140141 await r .delete ("test:hash" )
141142 await r .hset ("test:hash" , mapping = {"field1" : "value1" , "field2" : "value2" })
142- exp_time = datetime .now () + timedelta (seconds = 1 )
143+ exp_time = ( datetime .now () + timedelta (seconds = 2 )). replace ( microsecond = 0 )
143144 assert await r .hexpireat ("test:hash" , exp_time , "field1" ) == [1 ]
144- await asyncio .sleep (1 .1 )
145+ await asyncio .sleep (2 .1 )
145146 assert await r .hexists ("test:hash" , "field1" ) is False
146147 assert await r .hexists ("test:hash" , "field2" ) is True
147148
@@ -175,9 +176,9 @@ async def test_hexpireat_multiple_fields(r):
175176 "test:hash" ,
176177 mapping = {"field1" : "value1" , "field2" : "value2" , "field3" : "value3" },
177178 )
178- exp_time = int ((datetime .now () + timedelta (seconds = 1 )).timestamp ())
179+ exp_time = math . ceil ((datetime .now () + timedelta (seconds = 1 )).timestamp ())
179180 assert await r .hexpireat ("test:hash" , exp_time , "field1" , "field2" ) == [1 , 1 ]
180- await asyncio .sleep (1.5 )
181+ await asyncio .sleep (2.1 )
181182 assert await r .hexists ("test:hash" , "field1" ) is False
182183 assert await r .hexists ("test:hash" , "field2" ) is False
183184 assert await r .hexists ("test:hash" , "field3" ) is True
0 commit comments