When running a test that executes a background task that fails, test is hanging forever.
I am expecting that when calling broker.join with fail_fast=True, exception raised in the task will be propagated in the test into the broker.join call. Instead the test never finish.
Here is an example code, I can share the whole example Django project if needed.
# myapp/tests.py
@pytest.mark.django_db(transaction=True)
def test_register_user_task_using_invalid_input(broker, worker):
tasks.register_user.send("")
broker.join(tasks.register_user.queue_name, fail_fast=True)
worker.join()
assert User.objects.count() == 1
# myapp/tasks.py
@dramatiq.actor
def register_user(email):
if not email:
raise Exception("empty")
user = User.objects.create(email=email)
return user.id
When running a test that executes a background task that fails, test is hanging forever.
I am expecting that when calling
broker.join
withfail_fast=True
, exception raised in the task will be propagated in the test into thebroker.join
call. Instead the test never finish.Here is an example code, I can share the whole example Django project if needed.