I am new to Pytest in python .
I am facing a tricky scenario where I need to test for exit codes - exit(1) and exit(0) , using Pytest module. Below is the python program :
def sample_script():
count_file = 0
if count_file == 0:
print("The count of files is zero")
exit(1)
else:
print("File are present")
exit(0)
Now I want to test the above program for exit codes, exit(1) and exit(0) . Using Pytest how we can frame the test code so that we can test or asset the exit code of the function sample_script ?
Please help me.