I am new to pytest and testing. I have a simple program like below say hi.py
def foo():
print('hello world')
def bar():
print('hello python')
if __name__ == "__main__":
foo()
bar()
I can run the above program like
python3 hi.py
I have a couple of test cases in test_hi.py
like below
import pytest
def test_foo()
pass
def test_bar()
pass
To increase code coverage, I also want to test it as python3 hi.py
i.e. if __name__==__main__:
way. I dont know how will I do it using a test case from test_hi.py
. Please help. Thanks.
I am testing the module using pytest
python -m pytest --cov=hi.py