Python CLI program unit testing

后端 未结 9 2175
日久生厌
日久生厌 2020-12-24 12:43

I am working on a python Command-Line-Interface program, and I find it boring when doing testings, for example, here is the help information of the program:

         


        
9条回答
  •  失恋的感觉
    2020-12-24 13:37

    The short answer is yes, you can use unit tests, and should. If your code is well structured, it should be quite easy to test each component separately, and if you need to to can always mock sys.argv to simulate running it with different arguments.

提交回复
热议问题