question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

pytest.mark.skip/skipif is not working when pytest bdd decorators are added at function level

See original GitHub issue

Hi, I am trying to skip test case execution using pytest.mark.skipif() decorator. But its not working when I am using this marker with pytestbdd markers. Is there any solution available to resolve this issue?

Below is the sample code which I am trying to execute.

from pytest_bdd import (
    given,
    scenarios,
    then,
    when,
    parsers
)
a=5
scenarios('./a.feature')
@pytest.mark.skipif(a==5,reason='matched')
@given(parsers.parse('a is declared'))
def test_ios():
    assert 'not executed'

Test case is passing in any condition m_test.py::test_verify_markers PASSED [100%]

Thanks In Advance.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:14 (8 by maintainers)

github_iconTop GitHub Comments

2reactions
The-Compilercommented, Mar 17, 2021

Works fine for me as well. I suppose reporting it to pytest-bdd won’t get anywhere either as long as there’s no reproducer for this…

@aniket02k Could you please show the full pytest output with that reproducer?

1reaction
mrbean-bremencommented, Mar 15, 2021

Hm, works fine for me. Here is the output with your feature (this is under Windows, but that should not matter):


(Py37_new) c:\...\skip_with_scenario>pytest -v
SESSIONSTART
================================================= test session starts =================================================
platform win32 -- Python 3.7.1, pytest-6.2.2, py-1.9.0, pluggy-0.13.1 -- c:\dev\venv\py37_new\scripts\python.exe
cachedir: .pytest_cache
rootdir: c:\dev\questions, configfile: pytest.ini
plugins: bdd-4.0.2, dependency-0.5.1, forked-1.3.0, mock-3.2.0, xdist-2.2.1, order-1.0.0.dev0
collected 2 items

test_bdd_scen.py::test_ios SKIPPED (matched)                                                                     [ 50%]
test_bdd_scen.py::test_verify_markers PASSED                                                                     [100%]

============================================ 1 passed, 1 skipped in 0.08s =============================================

As you can see, I use pytest-bdd 4.0.2 with pytest 6.2.2 under Python 3.7. What versions and environment are you using?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Welcome to Pytest-BDD's documentation! — Pytest-BDD 6.1.1 ...
Functions decorated with the scenario decorator behave like a normal test ... pytest.mark.skip(reason="Not implemented yet") marker(function) return True ...
Read more >
How to implement pytest xfail mark with pytest-bdd?
I need to implement @pytest.mark.xfail for one of my step definition. But after adding this decorator, its not working as expected. Example >...
Read more >
Pytest-BDD Documentation - Read the Docs
Pytest -BDD Documentation, Release 6.1.1. 1.3 Scenario decorator. Functions decorated with the scenario decorator behave like a normal test ...
Read more >
behave - Automation Panda
Although it is not officially part of the Cucumber project, it functions very ... pytest-bdd is very similar to other Python BDD frameworks...
Read more >
how to develop tests for a Pokédex using BDD
One of the biggest problems in the software development process is ... In pytest-bdd, we do it by decorating the function with @given(), ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found