为什么向芹菜添加参数会导致Python测试出错?

为什么向芹菜添加参数会导致Python测试出错?,python,celery,python-mock,Python,Celery,Python Mock,我正在尝试测试芹菜应用程序这是我的代码 @celery.task(bind=True, default_retry_delay=30) def convert_video(gif_url, webhook): // doing something awesome return except Exception as exc: raise convert_video.retry(exc=exc) 在我的测试中,我有这个 server.convert_v

我正在尝试测试芹菜应用程序这是我的代码

@celery.task(bind=True, default_retry_delay=30)
def convert_video(gif_url, webhook):
    // doing something awesome
       return
    except Exception as exc:
       raise convert_video.retry(exc=exc)
在我的测试中,我有这个

server.convert_video.apply(args=('some_gif', 'http://www.company.com?attachment_id=123')).get()
在我添加了
bind=True、default\u retry\u delay=30之后,我得到了这个错误

TypeError:convert_video()正好接受2个参数(给定3个)


老实说,我从来没有用过芹菜,但是快速查看一下他们的
bind
参数:

bind参数意味着函数将是一个“绑定方法”,这样您就可以访问任务类型实例上的属性和方法


通常,只有当这是类上的方法而不是独立函数时,才会使用它。作为类上的方法,它的第一个参数是
self

您使用的是
bind
参数,这意味着传递给函数的第一个参数将是任务实例-它有效地使函数成为
任务
类的方法

@celery.task(bind=True, default_retry_delay=30)
def convert_video(self, gif_url, webhook):
    try:
        log.info('here we have access to task metadata like id: %s', self.request.id)
        return
    except Exception as exc:
        raise convert_video.retry(exc=exc)

如果这应该是一个方法,它需要声明一个
self
参数。但是如果我删除了
bind=True,default\u retry\u delay=30
它工作正常。如果你删除
bind=True
,或者设置
bind=False
,它也会工作正常。如果
bind=False
它工作正常,你是对的。