pytest-dev / pytest-dev/pytest-bdd

[question] step arguments in code generation

Open
#784 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
1.5k
Forks
251
Avg merge
43m
Merged PRs (30d)
2

Description

Is your feature request related to a problem? Please describe.

During code generation pytest-bdd generate ... of a feature, the step arguments are not parsed properly.

Is this the intended behaviour, or should I expect a smarter code generation?

Describe the solution you'd like

It would be nice to have the step arguments parsed properly, e.g.

Feature: comparison

  Scenario Outline: check less than
    Given a value of <value>
    When I have a value of 3
    Then no error should be raised

    Examples:
      | value |
      | 2     |
      | 1     |
      | 0     |

this generates:

...
@given('a value of <value>')
def _():
    """a value of <value>."""
    raise NotImplementedError

I'd expect this to generate something like:

@given(parsers.parse("a value of {value}"))
def given_a_value(value):
    """Given a value of <value>.
    `value` ...
    """
    raise NotImplementedError

Describe alternatives you've considered

Manual, but that's very cumbersome.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the pytest-bdd generate command and the feature-generation path that handles Scenario Outline steps. Compare the current generated output for with the requested parsed argument and parameterized function, then verify that generated step arguments are usable for the examples shown.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
testing
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.