nose: nose.plugins.plugintest
Utilities for testing plugins.
Classes
Highlighted methods are defined in this class.
A mixin for testing nose plugins in their runtime environment.
Subclass this and mix in unittest.TestCase to run integration/functional tests on your plugin. When setUp() is called, the stub test suite is executed with your plugin so that during an actual test you can inspect the artifacts of how your plugin interacted with the stub test suite.
Class Variables
- activate
- the argument to send nosetests to activate the plugin
- suitepath
- if set, this is the path of the suite to test. otherwise, you will need to use the hook, makeSuite()
- plugins
- the list of plugins to make available during the run. Note that this does not mean these plugins will be enabled during the run -- only the plugins enabled by the activate argument or other settings in argv or env will be enabled.
- args
- a list of arguments to add to the nosetests command, in addition to the activate argument
- env
- optional dict of environment variables to send nosetests
Methods
x.__init__(...) initializes x; see x.__class__.__doc__ for signature
execute the plugin on the internal test suite.
returns a suite object of tests to run (unittest.TestSuite())
If self.suitepath is None, this must be implemented. The returned suite object will be executed with all plugins activated. It may return None.
Here is an example of a basic suite object you can return
>>> import unittest >>> class SomeTest(unittest.TestCase): ... def runTest(self): ... raise ValueError("Now do something, plugin!") ... >>> unittest.TestSuite([SomeTest()]) # doctest: +ELLIPSIS <unittest.TestSuite tests=[<...SomeTest testMethod=runTest>]>
runs nosetests with the specified test suite, all plugins activated.
Attributes
Default value: None
Default value: None
Default value: None
Default value: {}
Default value: None
Default value: []
Default value: None
Methods
Attributes
Default value: None
Default value: None
Functions
Specialized version of nose.run for use inside of doctests that test test runs.
This version of run() prints the result output to stdout. Before printing, the output is processed by replacing the timing information with an ellipsis (...), removing traceback stacks, and removing trailing whitespace.
Use this version of run wherever you are writing a doctest that tests nose (or unittest) test result output.
Note: do not use doctest: +ELLIPSIS when testing nose output, since ellipses ("test_foo ... ok") in your expected test runner output may match multiple lines of output, causing spurious test passes!