I've built my pytest class in the following manner:
class Test_Exit_Code(object):
def setup_class(cls):
If 2==2:
# stop execution of the test class
def test_a(self):
assert True==True
As you can see inside the setup_class method i've inserted an IF , what i want to achieve in the if section is that if a certain condition appears to be true instead of the comment i want to return exit code 5 , i.e. no tests were collected . so far i haven't found any way to do it.
CodePudding user response:
You could try calling pytest.exit()
. Also it seems you are missing the classmethod
decorator
class Test_Exit_Code:
@classmethod
def setup_class(cls):
If 2==2:
pytest.exit("test exit code setup failed", returncode=5)