views:

51

answers:

2

Hello,

I'm not sure of how to get the nose module's __main__ handler to work. I have this at the end of my test module:

if __name__ == "__main__":
    import nose
    nose.main()

Which gives me:

----------------------------------------------------------------------
Ran 0 tests in 0.002s

OK

but it I run the same thing via the command line, it finds the tests and executes them:

MacBook-Pro:Storage_t meloam$nosetests FileManager_t.py 
............E..
======================================================================
ERROR: testStageOutMgrWrapperRealCopy (WMCore_t.Storage_t.FileManager_t.TestFileManager)
----------------------------------------------------------------------

SNIP

----------------------------------------------------------------------
Ran 15 tests in 0.082s

FAILED (errors=1)

I've been playing with passing different arguments to nose.main() but I can't find anything that works. Am I missing something really obvious?

Thanks

A: 

You need to use nose.core.TestProgram directly by passing it fake command line arguments. That I'm not sure though will if find your tests from the same module as you're using

Nailor