Nose test script with command line arguments

后端 未结 5 1421
被撕碎了的回忆
被撕碎了的回忆 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:36

    Just running nose and passing in parameters will not work as nose will attempt to interpret the arguments as nose parameters so you get the problems you are seeing.

    I do not think nose support parameter passing directly yet but this nose plug-in nose-testconfig Allows you to write tests like below:

    from testconfig import config
    def test_os_specific_code():
        os_name = config['os']['type']
        if os_name == 'nt':
            pass # some nt specific tests
        else:
            pass # tests for any other os
    

提交回复
热议问题