I have a main() function in python that gets command line arguments. Is there a way for me to write pytest tests for this function and define the arguments in the code?
The best solution I found so far is this
def test_main(): sys.argv = ["some_name", "abc"] res = main()
and for flags:
sys.argv.append("-f") sys.argv.append("v")