1

I have a TestMain.py that inits and runs the Nose tests and I am trying to enable code coverage within it. The tests are currently loaded as follow:

if __name__ == '__main__':
    # Some initialization code here, so command-line cannot be used
    # Coverage configuration here
    test_loader = nose.loader.TestLoader(workingDir = './tests')
    nose.core.TestProgram(testLoader = test_loader)

The only "documentation" I found about the plugin is this and it's terrible: https://nose.readthedocs.org/en/latest/plugins/cover.html. No hints at all about what the methods expect, in what order they must be called, and the source code is of no use (I am supposed to supply a parser, what's a parser?)

I need to configure options (cover-package and cover-erase) and enable html reporting.

Can someone point me to a comprehensive doc about this API or demonstrate how to use this plugin?

Thank you!

oz123
  • 27,559
  • 27
  • 125
  • 187
olivierr91
  • 1,243
  • 3
  • 13
  • 29
  • I'm not sure of the exact way to do it within Python. I usually have it all configured externally. However, it is considered a plugin. So maybe you need to look at how to include plugins, and go from there? I know it's not much help...but maybe it's something you haven't considered yet? – idjaw Feb 26 '16 at 17:47
  • Check this out, might help a bit: http://mahmoudimus.com/blog/2011/02/developing-a-nose-test-plugin-to-time-python-tests/ – idjaw Feb 26 '16 at 17:51
  • The guy wrote a nose plug-in, but still he does not show any example of the usage of its API unfortunately... – olivierr91 Feb 26 '16 at 22:02
  • You aren't meant to invoke nose plugins programmatically. They are loaded and called by nose itself. – Ned Batchelder Feb 27 '16 at 20:22

1 Answers1

0

I have solved my problem using a setup.cfg file as described here: http://nose.readthedocs.org/en/latest/api/commands.html. Nose will pick up the file whether the tests are started from the command-line or within the API. Shame on Nose developpers for providing such incomplete and low quality documentation.

olivierr91
  • 1,243
  • 3
  • 13
  • 29