Nose test script with command line arguments

后端 未结 5 1366
被撕碎了的回忆
被撕碎了的回忆 2021-02-04 06:54

I would like to be able to run a nose test script which accepts command line arguments. For example, something along the lines:

test.py

import nose, sys
         


        
5条回答
  •  太阳男子
    2021-02-04 07:32

    For now I am using the following hack:

    args = sys.argv[1:]
    sys.argv = sys.argv[0:1]
    

    which just reads the argument into a local variable, and then deletes all the additional arguments in sys.argv so that nose does not get confused by them.

提交回复
热议问题