Alex Rivera | Logout

Is there a way to get python's nose module to work the same in __main__ and on the command line?

Asked 2010-07-01T18:21:10.523
11

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

Edit
Report

1 Answer

8
if __name__ == '__main__':
    import nose
    nose.run(defaultTest=__name__)
answered 2010-11-05T05:44:33.613

Your Answer