Passing options to nose in a Python test script

前端 未结 2 1518
情话喂你
情话喂你 2020-12-16 00:29

Rather than running my nose tests from the command line, I\'m using a test runner that sets up a few things for all the tests, including a connection to a local test instanc

相关标签:
2条回答
  • 2020-12-16 00:59

    Nose does something sneaky with the first argument, so it is not parsed. My nose wrapper does something like this:

    import nose
    import sys
    
    argv = sys.argv[:]
    argv.insert(1, "--with-xunit")
    nose.main(argv=argv)
    

    As a bonus, this allows the clients of your program to use Nose arguments to control its behavior!

    0 讨论(0)
  • 2020-12-16 01:03

    Like this:

    import nose
    
    argv = ['fake', '--with-xunit']
    nose.main(argv=argv)
    

    The "fake" argument must be added to stand in for the executable name, as described in dbw's answer.

    0 讨论(0)
提交回复
热议问题