【发布时间】:2014-08-08 22:57:49
【问题描述】:
我目前正在使用 Behave(Python 的 BDD)并且一直在挖掘源代码以了解如何声明 @given、@when 和 @then 装饰器。
我走得最远的是查看step_registry.py,在那里我找到了似乎正在完成这项工作的函数setup_step_decorators(context=None, registry=registry)。
但是,我不太明白这些装饰器是如何创建的,因为它们似乎没有在源代码中以def when(...): 的形式显式声明。我的印象是它们是基于字符串列表 (for step_type in ('given', 'when', 'then', 'step'):) 声明的,然后通过调用 make_decorator() 进行处理。
谁能带我浏览代码并解释这些装饰器在哪里/如何声明?
您可以在这里访问source code of Behave。
【问题讨论】:
标签: python bdd python-decorators python-behave