def setup_function(func):
    global counter
counter += 1
if counter >= 3:
    pytest.exit('decided to stop the test run')

def test_one():
    pass

def test_two():
    pass
How to stop all tests from inside a test or setUp using unittest?