File tree Expand file tree Collapse file tree 2 files changed +14
-8
lines changed Expand file tree Collapse file tree 2 files changed +14
-8
lines changed Original file line number Diff line number Diff line change @@ -37,11 +37,17 @@ def key_prefix(request, redis):
37
37
38
38
@pytest .fixture (scope = "session" , autouse = True )
39
39
def cleanup_keys (request ):
40
- def cleanup_keys ():
41
- # Always use the sync Redis connection with finalizer. Setting up an
42
- # async finalizer should work, but I'm not suer how yet!
43
- from redis_om .connections import get_redis_connection as get_sync_redis
40
+ # Always use the sync Redis connection with finalizer. Setting up an
41
+ # async finalizer should work, but I'm not suer how yet!
42
+ from redis_om .connections import get_redis_connection as get_sync_redis
44
43
45
- _delete_test_keys (TEST_PREFIX , get_sync_redis ())
44
+ # Increment for every pytest-xdist worker
45
+ conn = get_sync_redis ()
46
+ once_key = f"{ TEST_PREFIX } :cleanup_keys"
47
+ conn .incr (once_key )
46
48
47
- request .addfinalizer (cleanup_keys )
49
+ yield
50
+
51
+ # Delete keys only once
52
+ if conn .decr (once_key ) == 0 :
53
+ _delete_test_keys (TEST_PREFIX , conn )
Original file line number Diff line number Diff line change @@ -137,7 +137,7 @@ async def test_full_text_search_queries(members, m):
137
137
138
138
assert actual == [member1 ]
139
139
140
- actual = await (m .Member .find (~ (m .Member .bio % "anxious" )).all ())
140
+ actual = await (m .Member .find (~ (m .Member .bio % "anxious" )).sort_by ( "age" ). all ())
141
141
142
142
assert actual == [member1 , member3 ]
143
143
@@ -433,7 +433,7 @@ async def test_all_pks(m):
433
433
bio = "This is a test user to be deleted." ,
434
434
)
435
435
436
- await member1 .save ()
436
+ await member1 .save ()
437
437
438
438
pk_list = []
439
439
async for pk in await m .Member .all_pks ():
You can’t perform that action at this time.
0 commit comments