问题 Below pytest code works fine, which increments value . import pytest pytest.value = 1 def test_1(): pytest.value +=1 print(pytest.value) def test_2(): pytest.value +=1 print(pytest.value) def test_3(): pytest.value +=1 print(pytest.value) Output: Prints 2 3 4 I don't want to execute test_2 , when value=2 Is it possible by pytest.dependency() ? If yes, how can i use variable value in pytest.dependency ? If not pytest.dependency , Any alternative ? or any better way of handling such scenarios ?