33====
44
55As part of the Celery fixture setup a 'ping' task is run which executes
6- before the `bind_settings ` fixture is executed. This means that if any code
6+ before the `_bind_settings ` fixture is executed. This means that if any code
77calls `Badger.is_configured()` (or similar), the `_local` ContextVar in the
88Celery runner thread will not have the configuration set.
99"""
@@ -29,7 +29,8 @@ def _check_log_errors(caplog):
2929 pytest .fail (f"log errors during tests: { errors } " )
3030
3131
32- def test_celery_task (celery_session_app , celery_session_worker , bind_settings ):
32+ @pytest .mark .usefixtures ("_bind_settings" )
33+ def test_celery_task (celery_session_app , celery_session_worker ):
3334 @celery_session_app .task (bind = True , base = Task )
3435 def add_normal (self , a , b ):
3536 assert self .request .get ("taskbadger_task" ) is not None , "missing task in request"
@@ -58,7 +59,8 @@ def add_normal(self, a, b):
5859 assert Badger .current .session ().client is None
5960
6061
61- def test_celery_task_with_args (celery_session_app , celery_session_worker , bind_settings ):
62+ @pytest .mark .usefixtures ("_bind_settings" )
63+ def test_celery_task_with_args (celery_session_app , celery_session_worker ):
6264 @celery_session_app .task (bind = True , base = Task )
6365 def add_with_task_args (self , a , b ):
6466 assert self .taskbadger_task is not None
@@ -86,7 +88,8 @@ def add_with_task_args(self, a, b):
8688 )
8789
8890
89- def test_celery_task_with_kwargs (celery_session_app , celery_session_worker , bind_settings ):
91+ @pytest .mark .usefixtures ("_bind_settings" )
92+ def test_celery_task_with_kwargs (celery_session_app , celery_session_worker ):
9093 @celery_session_app .task (bind = True , base = Task )
9194 def add_with_task_args (self , a , b ):
9295 assert self .taskbadger_task is not None
@@ -114,7 +117,8 @@ def add_with_task_args(self, a, b):
114117 create .assert_called_once_with ("new_name" , value_max = 10 , actions = actions , status = StatusEnum .PENDING )
115118
116119
117- def test_celery_record_args (celery_session_app , celery_session_worker , bind_settings ):
120+ @pytest .mark .usefixtures ("_bind_settings" )
121+ def test_celery_record_args (celery_session_app , celery_session_worker ):
118122 @celery_session_app .task (bind = True , base = Task )
119123 def add_with_task_args (self , a , b ):
120124 assert self .taskbadger_task is not None
@@ -146,7 +150,8 @@ def add_with_task_args(self, a, b):
146150 )
147151
148152
149- def test_celery_record_task_kwargs (celery_session_app , celery_session_worker , bind_settings ):
153+ @pytest .mark .usefixtures ("_bind_settings" )
154+ def test_celery_record_task_kwargs (celery_session_app , celery_session_worker ):
150155 @celery_session_app .task (bind = True , base = Task )
151156 def add_with_task_kwargs (self , a , b , c = 0 ):
152157 assert self .taskbadger_task is not None
@@ -182,7 +187,8 @@ def add_with_task_kwargs(self, a, b, c=0):
182187 )
183188
184189
185- def test_celery_record_task_args_custom_serialization (celery_session_app , celery_session_worker , bind_settings ):
190+ @pytest .mark .usefixtures ("_bind_settings" )
191+ def test_celery_record_task_args_custom_serialization (celery_session_app , celery_session_worker ):
186192 class A :
187193 def __init__ (self , a , b ):
188194 self .a = a
@@ -217,7 +223,8 @@ def add_task_custom_serialization(self, a):
217223 )
218224
219225
220- def test_celery_task_with_args_in_decorator (celery_session_app , celery_session_worker , bind_settings ):
226+ @pytest .mark .usefixtures ("_bind_settings" )
227+ def test_celery_task_with_args_in_decorator (celery_session_app , celery_session_worker ):
221228 @celery_session_app .task (
222229 bind = True ,
223230 base = Task ,
@@ -243,7 +250,8 @@ def add_with_task_args_in_decorator(self, a, b):
243250 create .assert_called_once_with (mock .ANY , status = StatusEnum .PENDING , monitor_id = "123" , value_max = 10 )
244251
245252
246- def test_celery_task_retry (celery_session_app , celery_session_worker , bind_settings ):
253+ @pytest .mark .usefixtures ("_bind_settings" )
254+ def test_celery_task_retry (celery_session_app , celery_session_worker ):
247255 """Note: When a task is retried, the celery task ID remains the same but a new TB task
248256 will be created.
249257
@@ -330,7 +338,8 @@ def add_direct(self, a, b):
330338 assert Badger .current .session ().client is None
331339
332340
333- def test_task_shared_task (celery_session_worker , bind_settings ):
341+ @pytest .mark .usefixtures ("_bind_settings" )
342+ def test_task_shared_task (celery_session_worker ):
334343 @celery .shared_task (bind = True , base = Task )
335344 def add_shared_task (self , a , b ):
336345 assert self .taskbadger_task is not None
@@ -354,7 +363,8 @@ def add_shared_task(self, a, b):
354363 assert Badger .current .session ().client is None
355364
356365
357- def test_task_signature (celery_session_worker , bind_settings ):
366+ @pytest .mark .usefixtures ("_bind_settings" )
367+ def test_task_signature (celery_session_worker ):
358368 @celery .shared_task (bind = True , base = Task )
359369 def task_signature (self , a ):
360370 assert self .taskbadger_task is not None
@@ -381,7 +391,8 @@ def task_signature(self, a):
381391 assert Badger .current .session ().client is None
382392
383393
384- def test_task_map (celery_session_worker , bind_settings ):
394+ @pytest .mark .usefixtures ("_bind_settings" )
395+ def test_task_map (celery_session_worker ):
385396 """Tasks executed in a map or starmap are not executed as tasks"""
386397
387398 @celery .shared_task (bind = True , base = Task )
@@ -408,7 +419,8 @@ def task_map(self, a):
408419 assert Badger .current .session ().client is None
409420
410421
411- def test_celery_task_already_in_terminal_state (celery_session_worker , bind_settings ):
422+ @pytest .mark .usefixtures ("_bind_settings" )
423+ def test_celery_task_already_in_terminal_state (celery_session_worker ):
412424 @celery .shared_task (bind = True , base = Task )
413425 def add_manual_update (self , a , b , is_retry = False ):
414426 # simulate updating the task to a terminal state
0 commit comments