Considering a simple program like:
- main.py
- Reader.py
- test_Reader.py
Let's assume Reader.py is 100% coverage-tested by test_Reader.py.
How would one go with testing a main that would look like this:
from Reader import myClass
import argparse
if __name__ == '__main__':
# argparsing eluded
parser = argparse.ArgumentParser(description='my descrition')
parser.add_argument('myarg1', nargs='?',
default = 1)
parser.add_argument('myarg2', nargs='?',
default = 1)
args = parser.parse_args()
myClass(args.myarg1, args.myarg2)
How would one go with that? My first argument was that the algorithm is so simple it does not require to be tested. However, I am not sure if there is a reason why you would need to test that.
I know mocking argparse requires some mocking as explained in this question : Pytest with argparse: how to test user is prompted for confirmation? But is it worth the effort to actually mock something that simple (all the actual operations are in the other module)?