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):
3737
3838@pytest .fixture (scope = "session" , autouse = True )
3939def 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
4443
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 )
4648
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):
137137
138138 assert actual == [member1 ]
139139
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 ())
141141
142142 assert actual == [member1 , member3 ]
143143
@@ -433,7 +433,7 @@ async def test_all_pks(m):
433433 bio = "This is a test user to be deleted." ,
434434 )
435435
436- await member1 .save ()
436+ await member1 .save ()
437437
438438 pk_list = []
439439 async for pk in await m .Member .all_pks ():
You can’t perform that action at this time.
0 commit comments