nose-devs/nose — Issue #237: Empty setuptools plugin causes nosetests nose breakage
Author: jpellerin
Created: 2011-12-14 16:04:51+00:00
State: closed

What steps will reproduce the problem?
1. tar zxf bad_plugin.tar.gz
2. cd bad_plugin
3. sudo python setup.py develop
4. cd /path/to/nose
5. nosetests --with-bad-plugin

Er, I think it's not actually a bad plugin -- the bugs are in nose, not in
the plugin. Note that it's a 0.9 plugin (by accident, but that seems to
reveal a bug).

This report really covers two bugs (and two patches), apologies for not
splitting it up.

What is the expected output? What do you see instead?

Expected: nose's own tests should pass with --with-bad-plugin
Got: Lots of output, including 7 failures, 1 error and the --help output
several times, complaining "nosetests: error: no such option:
--with-bad-plugin". It ends like this:

----------------------------------------------------------------------
Ran 246 tests in 6.244s

FAILED (failures=1, errors=7)

Here's some of the earlier output:

======================================================================
ERROR: Failure: ('BadPlugin' object has
no attribute 'loadTestsFromPath')
----------------------------------------------------------------------
Traceback (most recent call last):
File "/home/john/src/nose/nose/plugins/manager.py", line 130, in generate
result = meth(*arg, **kw)
File "/home/john/src/nose/nose/plugins/manager.py", line 266, in
loadTestsFromFile
return self.plugin.loadTestsFromPath(filename)
AttributeError: 'BadPlugin' object has no attribute 'loadTestsFromPath'

(repeated seven times)

======================================================================
FAIL: Doctest: plugintest_environment.rst
----------------------------------------------------------------------
Traceback (most recent call last):
File "doctest.py", line 2112, in runTest
raise self.failureException(self.format_failure(new.getvalue()))
DocTestFailureException: Failed doctest test for plugintest_environment.rst
File
"/home/john/src/nose/functional_tests/doc_tests/test_issue097/plugintest_environment.rst",
line 0

----------------------------------------------------------------------
File
"/home/john/src/nose/functional_tests/doc_tests/test_issue097/plugintest_environment.rst",
line 81, in plugintest_environment.rst
Failed example:
run(suite=unittest.TestSuite(tests=[]),
plugins=[PrintEnvPlugin()]) # doctest: +REPORT_NDIFF
Exception raised:
Traceback (most recent call last):
File "doctest.py", line 1212, in __run
compileflags, 1) in test.globs
File "", line 2, in
plugins=[PrintEnvPlugin()]) # doctest: +REPORT_NDIFF
File "/home/john/src/nose/nose/plugins/plugintest.py", line 195, in run
run(*arg, **kw)
File "/home/john/src/nose/nose/core.py", line 367, in run
return TestProgram(*arg, **kw).success
File "/home/john/src/nose/nose/core.py", line 219, in __init__
argv=argv, testRunner=testRunner, testLoader=testLoader)
File "unittest.py", line 767, in __init__
self.parseArgs(argv)
File "/home/john/src/nose/nose/core.py", line 236, in parseArgs
self.config.configure(argv, doc=TestProgram.__doc__)
File "/home/john/src/nose/nose/config.py", line 120, in configure
options, args = parser.parse_args(argv)
File "optparse.py", line 1380, in parse_args
self.error(str(err))
File "optparse.py", line 1562, in error
self.exit(2, "%s: error: %s\n" % (self.get_prog_name(), msg))
File "optparse.py", line 1552, in exit
sys.exit(status)
SystemExit: 2

What version of the product are you using? On what operating system?

http://python-nose.googlecode.com/svn/trunk revision 390.

I see the same problems with
http://python-nose.googlecode.com/svn/branches/0.10.0-stable revision 390.

Please provide any additional information below.

The first problem is that .loadTestsFromFile is missing the hasattr check
that the other methods have. I assume that's a bug, but I'm not familiar
with the 0.9 API. First attached patch tests that nothing goes wrong when
empty plugins are used. The test already passes. I didn't add the obvious
test that runs an empty plugin in the ZeroNinePlugin manager, or add the
missing hasattr check, because I'm not sure what the expected behaviour is.

The second problem is that nose.plugins.plugintest.run() inherits its argv
from sys.argv. This shows up in plugintest_environment, which is testing
for the analogous leakage problem with os.environ. Second patch addresses
that, with extended plugintest_environment.rst to test it.

Will upload patches when I have issue ID.

Google Code Info:
Issue #: 119
Author: j...@pobox.com
Created On: 2007-10-20T17:45:48.000Z
Closed On: 2007-11-12T22:21:01.000Z