How can I skip a test if another test fails with py.test?
pytest, python
Solution
You can use plugin for pytest called pytest-dependency.
The code can look like this:
import pytest
@pytest.mark.dependency() #First test have to have mark too
def test_function_one():
assert 0, "Deliberate fail"
@pytest.mark.dependency(depends=["test_function_one"])
def test_function_two():
pass #but will be skipped because first function failed
Problem
Let's say I have these test functions: ``` def test_function_one(): assert # etc... def test_function_two(): # should only run if test_function_one passes assert # etc. ``` How can I make sure that test_function_two only runs if test_function_one passes (I'm hoping that it's possible)? Edit: I need this because test two is using the property that test one verifies.