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

runner: create_scenario_line_references() -- Scenario detection does not work for Non-English languages #77

Closed
jenisys opened this issue Jun 8, 2023 · 2 comments
Labels
bug Something isn't working fixed

Comments

@jenisys
Copy link

jenisys commented Jun 8, 2023

Describe the bug
Scenario versus ScenarioOutline detection logic in behave/runner.py is extremely brittle
because it relies on English keyword "Scenario".
This solution will not work in other languages except in English.
In addition, by now Gherkin supports multiple aliases for Scenario (even in English language).
Therefore, it is better to check is-instance-of(Scenario) instead of checking the keyword, like:

# -- FILE: behavex/runner.py
from behave.model import ScenarioOutline   # ADDED
...
def create_scenario_line_references(features):
    ...
    for feature in features:
        ...
        for scenario in feature.scenarios:
            # ORIG: if scenario.keyword == u'Scenario':  # -- PROBLEM-POINT was here
            if not isinstance(scenario, ScenarioOutline):  # NEW_SOLUTION_HERE
                feature_lines[scenario.name] = scenario.line
            else:
                ...

To Reproduce
Steps to reproduce the behavior:

  1. Run behavex features against the behave/tools/test-features/french.feature (using keyword: Scénario (with accept)
  File "/.../behavex/runner.py", line 2xx, in create_scenario_line_references
    for scenario_multiline in scenario.scenarios:
AttributeError: 'Scenario' object has no attribute 'scenarios'

Expected behavior
Scenario detection logic should be independent of keywords and should work for any language.

Version Info:

  • behavex v2.0.2 (current HEAD of repository)
@anibalinn
Copy link
Collaborator

Fix implemented in the upcoming release branch release_2.0.2

@anibalinn
Copy link
Collaborator

Fix released in version 3.0.0: https://pypi.org/project/behavex/3.0.0/
branch release_3.0.0
Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working fixed
Projects
None yet
Development

No branches or pull requests

2 participants