I am familiar with behave in which I can define data for a step like so:
Feature: My feature
Scenario: My scenario
Given some data
| order_nr | customer_name | delivery_date |
| 1 | John Doe | 2023-10-01 |
| 2 | Jane Smith | 2023-10-02 |
The table is available to the Python step code as the “.table” attribute in the
Context
variable passed into each step function. The table for the example above could be accessed like so:
@given('a set of specific users')
def step_impl(context):
for row in context.table:
model.add_user(name=row['name'], department=row['department'])
I like having the data visible to the person reading the feature file however I'm using pytest-bdd. I would like to achieve the same using pytest-bdd.
pytest-bdd however does not have the equivalent of the Context
variable therefore I don't know how to achieve this. Is there a way to pass data from the feature file to a step definition when using pytest-bdd?
Looks like support for datatables got added 18 days ago https://github.com/pytest-dev/pytest-bdd/pull/712
Just have to wait for pytest-bdd 8.x to get released. Hopefully won't be long.