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
nose can be integrated with DocTest by using with-doctest option in athe bove command line. The result will be true if the test run is successful, or false if it fails or raises an uncaught exception. nose supports fixtures (setup and teardown methods) at the package, module, class, and test level.
Nose is a popular test automation framework in Python that extends unittest to make testing easier. The other advantages of using the Nose framework are the enablement of auto discovery of test cases and documentation collection.
For posterity's sake, this is what I use:
if __name__ == '__main__':
import nose
nose.run(argv=[__file__, '--with-doctest', '-vv'])
The --with-doctests
will also execute your doctests in the same file.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With