I'm using Pytest to run test on one file that goes like this:
def function():...
def test_function():...
def main():...
main()
I want Pytest to exclude the line that calls main, is it possible?
I'm using Pytest to run test on one file that goes like this:
def function():...
def test_function():...
def main():...
main()
I want Pytest to exclude the line that calls main, is it possible?
Pytest will execute only those functions with test
as a prefix. Since you have already have a function def function()
at the start there can be some issues running the entire test case.
As @hoefling commented, pytest can not skip the code.
Try adding the following at the end of you code:
if __name__=='__main__':
main()