Skip to content

Commit cf16c4c

Browse files
committed
optional args and kwargs
1 parent 81bb6a3 commit cf16c4c

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

codeforlife/tests/celery.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
Created on 01/04/2025 at 16:57:19(+01:00).
44
"""
55

6+
import typing as t
67
from importlib import import_module
78
from unittest import TestCase
89

@@ -46,7 +47,12 @@ def apply_periodic_task(self, beat_name: str):
4647
args, kwargs = beat.get("args", tuple()), beat.get("kwargs", {})
4748
task.apply(*args, **kwargs)
4849

49-
def apply_task(self, name: str, args: Args, kwargs: KwArgs):
50+
def apply_task(
51+
self,
52+
name: str,
53+
args: t.Optional[Args] = None,
54+
kwargs: t.Optional[KwArgs] = None,
55+
):
5056
"""Apply a task.
5157
5258
Args:
@@ -55,4 +61,4 @@ def apply_task(self, name: str, args: Args, kwargs: KwArgs):
5561
kwargs: The keyword args to pass to the task.
5662
"""
5763
task: Task = self.app.tasks[f"{settings.SERVICE_NAME}.{name}"]
58-
task.apply(*args, **kwargs)
64+
task.apply(*(args or tuple()), **(kwargs or {}))

0 commit comments

Comments
 (0)