1
+ import math
1
2
import time
2
3
from datetime import datetime , timedelta
3
4
@@ -147,9 +148,9 @@ def test_hpexpire_multiple_condition_flags_error(r):
147
148
def test_hexpireat_basic (r ):
148
149
r .delete ("test:hash" )
149
150
r .hset ("test:hash" , mapping = {"field1" : "value1" , "field2" : "value2" })
150
- exp_time = int ((datetime .now () + timedelta (seconds = 1 )).timestamp ())
151
+ exp_time = math . ceil ((datetime .now () + timedelta (seconds = 1 )).timestamp ())
151
152
assert r .hexpireat ("test:hash" , exp_time , "field1" ) == [1 ]
152
- time .sleep (1 .1 )
153
+ time .sleep (2 .1 )
153
154
assert r .hexists ("test:hash" , "field1" ) is False
154
155
assert r .hexists ("test:hash" , "field2" ) is True
155
156
@@ -158,9 +159,9 @@ def test_hexpireat_basic(r):
158
159
def test_hexpireat_with_datetime (r ):
159
160
r .delete ("test:hash" )
160
161
r .hset ("test:hash" , mapping = {"field1" : "value1" , "field2" : "value2" })
161
- exp_time = datetime .now () + timedelta (seconds = 1 )
162
+ exp_time = ( datetime .now () + timedelta (seconds = 2 )). replace ( microsecond = 0 )
162
163
assert r .hexpireat ("test:hash" , exp_time , "field1" ) == [1 ]
163
- time .sleep (1 .1 )
164
+ time .sleep (2 .1 )
164
165
assert r .hexists ("test:hash" , "field1" ) is False
165
166
assert r .hexists ("test:hash" , "field2" ) is True
166
167
@@ -194,9 +195,9 @@ def test_hexpireat_multiple_fields(r):
194
195
"test:hash" ,
195
196
mapping = {"field1" : "value1" , "field2" : "value2" , "field3" : "value3" },
196
197
)
197
- exp_time = int ((datetime .now () + timedelta (seconds = 1 )).timestamp ())
198
+ exp_time = math . ceil ((datetime .now () + timedelta (seconds = 1 )).timestamp ())
198
199
assert r .hexpireat ("test:hash" , exp_time , "field1" , "field2" ) == [1 , 1 ]
199
- time .sleep (1 .1 )
200
+ time .sleep (2 .1 )
200
201
assert r .hexists ("test:hash" , "field1" ) is False
201
202
assert r .hexists ("test:hash" , "field2" ) is False
202
203
assert r .hexists ("test:hash" , "field3" ) is True
0 commit comments