smarie / python-pytest-steps

A tiny package to ease the creation of test steps with shared intermediate results/state.
https://smarie.github.io/python-pytest-steps/
BSD 3-Clause "New" or "Revised" License
57 stars 5 forks source link

`StepYieldError` when step ids are present in other parameter ids #21

Closed smarie closed 5 years ago

smarie commented 5 years ago
import pytest
from pytest_steps import test_steps

@test_steps('a', 'b')
@pytest.mark.parametrize('dummy_param', ['a', 'b'], ids="p={}".format)
def test_step_id_conflicts(dummy_param):
    yield 'a'
    yield 'b'

yields:

StepYieldError: Error collecting results from step 'b': received 'a' from the `yield` statement, which is different from the current step or step name. Please either use `yield`, `yield 'b'` or wrap your step with `with optional_step(...) as my_step:` and use `yield my_step`

The issue happens because we generate a unique id for each combination of parameters except step. This unique id is based on the string id right now, where a conflict happens because the string id of the step parameter happends in the string id of the other.