Closed kimsappi closed 2 years ago
I also saw the same error but in my case I have both a @given
and a @when
step on the same function in that order (@given
declared first and @when
second). I believe both steps are registered but only the first parser is ever used.
e.g.: In my test the @when
step gets executed but the string is parsed using the statement from the @given
parser which does not match and then returns None
here:
def parse(self, string, evaluate_result=True):
"""Match my format to the string exactly.
Return a Result or Match instance or None if there's no match.
"""
m = self._match_re.match(string)
if m is None:
return None
So my test fails with the following error:
def parse_arguments(self, name: str) -> dict[str, Any]:
"""Get step arguments.
:return: `dict` of step arguments
"""
> return cast(Dict[str, Any], self.parser.parse(name).named)
E AttributeError: 'NoneType' object has no attribute 'named'
I made a fix in #530, can you try it out before I make a release to check if it fixes it for your project?
You can install it using:
pip install git+https://github.com/pytest-dev/pytest-bdd.git@15e1a8aa201384e9cd7d026af0200f5942b2cadd#egg=pytest-bdd
@youtux yes it is working for me (my project has 1267 tests)
I only had to convert some scenarios where I used vertical example tables which is not supported anymore, otherwise upgrading from 5.0.0 to this fixed version works.
Thank you for the swift work. Tested it against some of our projects, and they work with this version.
Thanks for testing, I'll probably release 6.0.1 tomorrow.
Version 6.0.1 is out.
It seems like you only created a tag here in Github, but the latest release is still 6.0.0
. On Pypi it was updated, and the latest version is 6.0.1
.
Having multiple step aliases with parsing is no longer supported as of pytest-bdd 6.0.0. The error is reproducible by varying the order of the decorators (
@given(...)
in the following example): only the top-most decorator ever works.Example:
Input:
Expected output (pytest-bdd==5.0.0):
Real output (pytest-bdd==6.0.0):
Environment