Try to search your question here, if you can't find : Ask Any Question Now ?

pytest.config.getoption alternative is failing

HomeCategory: stackoverflowpytest.config.getoption alternative is failing
pragati asked 2 weeks ago

My setup is such that; pytest executes nothing while pytest --first-test executes the target function test_skip.

In order to determine whether a certain test should be conducted or not, this is what I have been using:

skip_first = pytest.mark.skipif(
        not (
                or os.environ.get('FULL_AUTH_TEST')
                ), reason="Skipping live"

def test_skip():

Now that, pytest.config.getoption is being deprecated, I am trying to update my code. This is what I have written:

def skip_first(request):
    def _skip_first():
        return pytest.mark.skipif(
            not (
                or os.environ.get('FULL_AUTH_TEST')),
    return _skip_first()

# And, to call:

def test_skip(skip_first):
   assert 1==2

However, whether I do pytest or pytest --first-test, test_skip will always execute. But, the skip_first seems to be working fine – Inserting a print statement shows skip_first = MarkDecorator(mark=Mark(name='skipif', args=(False,), kwargs={'reason': 'Skipping first'})), when --first-test is given, and args=(True) when given. (Same thing was observed when using the first setup).

Am I missing something?? I even tried to return the function _skip_first instead of it’s output in the def skip_first but no difference.

When using a test class, the manual indicates we need to use @pytest.mark.usefixtures("fixturename") but that proved to be of no use either (with classes).

Ideas? This is my system: platform linux -- Python 3.6.7, pytest-4.0.2, py-1.7.0, pluggy-0.8.0

1 Answers
Best Answer
Arben answered 2 weeks ago
Your Answer

14 + 17 =

Popular Tags

WP Facebook Auto Publish Powered By :