Commit 64084ac
committed
test: upgrade pytest-asyncio and add loop scoping
Upgrade pytest-asyncio from 0.20.1 to 0.24.0+ and configure
event loop scope to prevent fixture crashes.
requirements.txt changes:
- pytest>=8.3,<9.0 (was >=7.1.2)
- pytest-asyncio>=0.24.0,<0.25.0 (was ==0.20.1)
conftest.py changes:
- Remove manual event_loop fixture override (deprecated in 0.24+)
- Rewrite async_client fixture to bypass async_pool. With
session-scoped loops, the standalone ConnectionPool in async_pool
retains connections with stale loop references when df_server
restarts between test classes. Now async_client creates Redis
directly with connection params, letting Redis manage its own
internal pool and adding proper aclose() cleanup. This fixes 7
failing tests (test_publish_stuck, test_nested_client_pause,
test_cron_snapshot, test_set_cron_snapshot, test_basic_memory_usage,
test_mixed_append, test_tiered_replication_with_hashes).
pytest.ini changes:
- Add asyncio_default_fixture_loop_scope=session
pytest-asyncio 0.24+ forbids manual event_loop overrides and
requires explicit loop scope configuration. We use session scope
because:
1. df_factory and other fixtures are class-scoped
2. Many async tests are module-level functions (not in classes)
3. session scope supports both patterns without UsageError
Upper bounds prevent pip from installing pytest 9.x and
pytest-asyncio 1.x, which conflict with dragonfly-fakeredis-tests.
snapshot_test.py changes:
- test_s3_snapshot, test_s3_save_local_dir: replace async_client
fixture with df_server.client(). With session-scoped loops,
the shared async_client pool holds stale connections from a
previous df_server instance, causing "Future attached to a
different loop". Creating a fresh client per test avoids this
(same pattern used by test_s3_reload_snapshot_after_restart).
Signed-off-by: Gil Levkovich <69595609+glevkovich@users.noreply.github.com>1 parent e426a6f commit 64084ac
4 files changed
Lines changed: 16 additions & 13 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
250 | 250 | | |
251 | 251 | | |
252 | 252 | | |
253 | | - | |
254 | | - | |
255 | | - | |
256 | | - | |
257 | | - | |
258 | | - | |
259 | | - | |
260 | 253 | | |
261 | 254 | | |
262 | 255 | | |
| |||
363 | 356 | | |
364 | 357 | | |
365 | 358 | | |
366 | | - | |
| 359 | + | |
367 | 360 | | |
368 | 361 | | |
369 | 362 | | |
370 | | - | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
371 | 370 | | |
372 | 371 | | |
373 | 372 | | |
374 | 373 | | |
| 374 | + | |
375 | 375 | | |
376 | 376 | | |
377 | 377 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
9 | | - | |
| 9 | + | |
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
13 | | - | |
| 13 | + | |
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
390 | 390 | | |
391 | 391 | | |
392 | 392 | | |
393 | | - | |
| 393 | + | |
| 394 | + | |
394 | 395 | | |
395 | 396 | | |
396 | 397 | | |
| |||
460 | 461 | | |
461 | 462 | | |
462 | 463 | | |
463 | | - | |
| 464 | + | |
| 465 | + | |
464 | 466 | | |
465 | 467 | | |
466 | 468 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
| 8 | + | |
8 | 9 | | |
9 | 10 | | |
10 | 11 | | |
| |||
0 commit comments