Closed blueyed closed 9 years ago
I cannot see where the "Some\nExtra\nLines" is coming from. Probably the
assertion needs to be fixed / enhanced to handle / compare the indentation.
it comes from the given, because like any given it's fixture which you can access later in other given, when, then functions
about the rename i totally agree and will do
it comes from the given
Ah, I see. Missed that.
But then the text
argument is invalid here maybe?
I see that i_have_text
comes from the when
, but not where text
is coming from.
text is coming from the step text as a step argument It's probably a bit too complicated example
@given(re.compile(r'I have a step with:\n(?P<text>.+)', re.DOTALL))
def i_have_text(text):
return text
this is an argumented step so it's function gets an argument 'text' because it's a regex group name cool that you've pointed out this place - because it uses an outdated way of declaring argumented steps
So this means that any step arguments are available in the then
automatically / when requested?
I would have expected that only fixtures (and pytest-bdd's extension of them) could be requested/used as arguments.
Anyway, it would certainly benefit from some explanation.. :)
any step argument is injected into pytest's request as a normal fixture, no difference, so you access it in natural way. this allows you to 'mark.parametrize' your test with argumented given, without having to decorate the actual test! And if the name of the argument clashes with existing fixture name, it will override it - so very powerful and we use that quite a lot. pytest-bdd is build on top of fixtures and only fixtures :) yes, i'll add more to the step arguments section - about that fact that step arguments are fixtures as well.
Thanks!
Sounds very powerful indeed.
The documentation on https://github.com/pytest-dev/pytest-bdd#multiline-steps (https://github.com/pytest-dev/pytest-bdd/blame/master/README.rst#L317-L321) seems to be wrong:
I cannot see where the "Some\nExtra\nLines" is coming from. Probably the assertion needs to be fixed / enhanced to handle / compare the indentation.
Also, while at it, the function should be renamed. It's not about cucumbers in this section.. :)