Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Parsers should parse scenario outline like standard scenarios #409

Closed
dcendents opened this issue Mar 26, 2021 · 1 comment · Fixed by #445
Closed

Parsers should parse scenario outline like standard scenarios #409

dcendents opened this issue Mar 26, 2021 · 1 comment · Fixed by #445

Comments

@dcendents
Copy link
Contributor

Hi,

  • I use cfparse when I want to parse a list.
  • I use scenario outlines when I want to test my scenario with different values

I cannot mix both conditions together.

e.g.:

Scenario Outline: mix case
  Given the emails <emails>
  ...

Examples:
  | emails |
  | someone@somewhere.com |
  | someone@somewhere.com, someone.else@somewhere.com |


Scenario: other scenario
  Given the emails email1@server.net, email2@server.net
  ...

It would be very useful if I could then have the following step

@given(parsers.cfparse("Given the emails {emails:str+}". extra_types=dict(str=str)), target_fixture="emails")
def emails(emails)
    return emails

Ok I could split the list myself, but it's ugly

@given("Given the emails <emails>")
@given(parsers.cfparse("Given the emails {emails:str+}". extra_types=dict(str=str)), target_fixture="emails")
def emails(emails)
    return emails if isinstance(emails, list) else emails.split(",")

The same kind of support has been asked a few times in #293 but since it has nothing to do with the original problem I fear it has been lost through all the discussions.

Thanks

@TBBle
Copy link
Contributor

TBBle commented Aug 23, 2021

We've had to use exactly this workaround of the double-@given, once with <> examples and once with parsers.parse, so implementing this would be great.

I recently worked in Godog (the official Cucumber implementation for Go) and it works this way; the steps never see the <example> placeholder, they parse the resulting interpolated statement like if it was written literally, and for pytest-bdd that would let us apply all the various benefits of parsers.X (built-in or custom) as desired.

I haven't checked #433 to see if that's how it worked, but it was reverted in #440 so I guess that's academic.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants