pytest-dev / pytest-dev/pytest-bdd

pytest_bdd_apply_tag does not detect Gherkin example tags

Open
#774 3 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.
Tags on example tables are not picked up by the pytest_bdd_apply_tag.

i.e.

Feature: My Feature
    Scenario: My scenario case <case>
    
    Examples:
        | case |
        | 1    |
        | 2    |

    @xfail @supresswarning=DeprecationWarning
    Examples:
        | case |
        | 3    |

case 3 does get marked with xfail, but pytest_bdd_apply_tag never sees either tag.

Describe the solution you'd like
All tag locations supported by Gherkin features are intercepted by the tag hook.

Describe alternatives you've considered
Use custom tags on the entire scenario
Use @xfail and @skip tags without specifying a reason
Use request.node.add_marker() in relevent python steps that can branch on example parameters

Additional context
@skip and @xfail are working for example tables, but they and new tags can't be customised.

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 by locating the pytest_bdd_apply_tag hook and the existing handling for tags on Gherkin examples, then inspect related tests for @skip and @xfail. Add coverage for custom tags placed on example tables and verify that the hook receives them while existing example-table behavior remains unchanged.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
testing
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
62/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.