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

Unexpected behavior in scenario outline #389

Closed
vytautas-ziurlis-youtility opened this issue Sep 17, 2020 · 2 comments
Closed

Unexpected behavior in scenario outline #389

vytautas-ziurlis-youtility opened this issue Sep 17, 2020 · 2 comments

Comments

@vytautas-ziurlis-youtility

Hi,

I have noticed unexpected behavior when using scenario outline. Here's a simple example to demonstrate it:

File test.scenario:

Feature: Test feature

  Scenario Outline: Scenario 1
    When Action "A" is taken
    And Some other action "<action>" is taken

    Examples: Actions
      | action |
      | B      |

File steps.py:

import pytest
from pytest_bdd import scenarios, given, when, then, parsers

scenarios('test.feature', example_converters={ 'action': str })

@when(parsers.parse('Action "{action}" is taken'))
def take_action1(action):
    print('take_action1:%s'%action)
    pass

@when('Some other action "<action>" is taken')
def take_action2(action):
    print('take_action2:%s'%action)
    pass

In this particular case I would expect to see the following in the output:

take_action1:A
take_action2:B

However, what I see is this:

take_action1:A
take_action2:A

Strangly this problem goes away if I rename action argument for one of the steps, for example:

@when(parsers.parse('Action "{action}" is taken'))
def take_action1(action):
    print('take_action1:%s'%action)
    pass

@when('Some other action "<action2>" is taken')
def take_action2(action2):
    print('take_action2:%s'%action2)
    pass

I have a feeling that arguments are somehow "cached" or memoized by name and was wondering is this expected behavior?

@WilliamWCYoung
Copy link

I second this finding, I was trying to debug this for ages and changing the name to something unique fixed it. It would be great to be able to reuse the names as they're not actually used within the same context?

jsa34 added a commit that referenced this issue Nov 29, 2024
Tidy up imports in tests in the same file as new test written.

Resolves #389
@jsa34
Copy link
Collaborator

jsa34 commented Dec 3, 2024

Resolved in #745

@jsa34 jsa34 closed this as completed Dec 3, 2024
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.

3 participants