Skip to content

Commit f447b91

Browse files
Copilotyyyyyyyan
andauthored
SEP-1735: Switch unused worker_loop_env requests to usefixtures in test_celery_settings_override.py (#1451)
Four tests in `TestWorkerRefresherHandlers` requested the `worker_loop_env` fixture purely for its setup side effects (dedicated event loop, in-memory Tasks DB) without ever reading its returned `(loop, session_maker)` tuple, leaving the module inconsistent with the sibling suite's `usefixtures` convention for the same intent. ### Changes - Switched `test_shutdown_cancels_and_drains_started_refresher` and `test_init_is_idempotent_when_already_running` from a `worker_loop_env` parameter with a discarded `loop, _ = worker_loop_env` unpack to `@pytest.mark.usefixtures("worker_loop_env")` - Switched `test_init_forwards_a_budget_from_worker_proc_alive_timeout` and `test_init_returns_with_a_running_refresher_when_the_seed_hangs` from an unused `worker_loop_env: WorkerLoopEnv` parameter to `@pytest.mark.usefixtures("worker_loop_env")` - Left `test_post_init_override_visible_after_loop_driven` and `test_overridden_ttl_excludes_recently_locked_row` unchanged, since both actually read `loop`/`maker` from the unpacked tuple ```python @pytest.mark.usefixtures("worker_loop_env") def test_shutdown_cancels_and_drains_started_refresher(self): """Stop and drain the started refresher, clearing the handle.""" start_settings_override_refresher() ... ``` No test assertions or fixture setup/teardown behavior changed — this is a call-site style change only. --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: yyyyyyyan <24644216+yyyyyyyan@users.noreply.github.com> Co-authored-by: yyyyyyy <yan.orestes@percona.com>
1 parent 12aa067 commit f447b91

1 file changed

Lines changed: 6 additions & 7 deletions

File tree

tests/app/tasks/test_celery_settings_override.py

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,6 @@
6363
from tests.app.factories import TaskFactory
6464

6565
ANCHOR = datetime(2026, 1, 1, 12, 0, 0, tzinfo=UTC)
66-
WorkerLoopEnv = tuple[asyncio.AbstractEventLoop, async_sessionmaker]
6766

6867

6968
def _write_cert(path: Path, *, not_valid_after: datetime) -> None:
@@ -300,9 +299,9 @@ def test_shutdown_is_noop_when_not_started(self, monkeypatch):
300299
stop_settings_override_refresher()
301300
assert celery_module._refresher.task is None
302301

303-
def test_shutdown_cancels_and_drains_started_refresher(self, worker_loop_env):
302+
@pytest.mark.usefixtures("worker_loop_env")
303+
def test_shutdown_cancels_and_drains_started_refresher(self):
304304
"""Stop and drain the started refresher, clearing the handle."""
305-
loop, _ = worker_loop_env
306305
start_settings_override_refresher()
307306
task = celery_module._refresher.task
308307
assert task is not None
@@ -312,9 +311,9 @@ def test_shutdown_cancels_and_drains_started_refresher(self, worker_loop_env):
312311
assert celery_module._refresher.task is None
313312
assert task.cancelled() or task.done()
314313

315-
def test_init_is_idempotent_when_already_running(self, worker_loop_env):
314+
@pytest.mark.usefixtures("worker_loop_env")
315+
def test_init_is_idempotent_when_already_running(self):
316316
"""Keep the running refresher and start no second task on re-entry."""
317-
loop, _ = worker_loop_env
318317
start_settings_override_refresher()
319318
first_task = celery_module._refresher.task
320319
assert first_task is not None
@@ -340,9 +339,9 @@ def test_post_init_override_visible_after_loop_driven(self, worker_loop_env):
340339
loop.run_until_complete(refresh_all(lambda: maker, _tasks_proxies()))
341340
assert baseline + 1234 == tasks_settings.STALENESS_THRESHOLD_SECONDS
342341

342+
@pytest.mark.usefixtures("worker_loop_env")
343343
def test_init_forwards_a_budget_from_worker_proc_alive_timeout(
344344
self,
345-
worker_loop_env: WorkerLoopEnv,
346345
monkeypatch: pytest.MonkeyPatch,
347346
) -> None:
348347
"""Derive the seed budget from Celery's prefork liveness deadline."""
@@ -354,9 +353,9 @@ def test_init_forwards_a_budget_from_worker_proc_alive_timeout(
354353

355354
assert recorded["seed_timeout"] == pytest.approx(6.0 * SEED_TIMEOUT_FRACTION)
356355

356+
@pytest.mark.usefixtures("worker_loop_env")
357357
def test_init_returns_with_a_running_refresher_when_the_seed_hangs(
358358
self,
359-
worker_loop_env: WorkerLoopEnv,
360359
monkeypatch: pytest.MonkeyPatch,
361360
) -> None:
362361
"""Keep the periodic refresher after a hanging seed hits its budget."""

0 commit comments

Comments
 (0)