I am currently using Behave (BDD for Python) and have been digging in the source code to understand how the @given
, @when
and @then
decorators are being declared.
The farthest I've gone is to look at step_registry.py
where I found the function setup_step_decorators(context=None, registry=registry)
which appears to be doing the job.
However, I don't quite understand how these decorators are created since they don't appear to be explicitly declared in the source code in the form of a def when(...):
. I am under the impression that they are declared based on a list of strings (for step_type in ('given', 'when', 'then', 'step'):
) that is then processed by a call to make_decorator()
.
Can someone walk me through the code and explain where/how these decorators are being declared?
Here is where you can get access to the source code of Behave.