nose-devs/nose — Issue #296: test methods containing doctests never run, with --doctest
Author: jpellerin
Created: 2011-12-14 16:06:48+00:00
State: open

What steps will reproduce the problem?
1. nosetests -v --with-doctest test_good.py
2. nosetests -v --with-doctest test_bad.py

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

Expected:

test_bar (test_good.TestFoo) ... FAIL
test_foo (test_good.TestFoo) ... FAIL

======================================================================
FAIL: test_bar (test_good.TestFoo)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/scratch/jlee/nose_bug_1/test_good.py", line 9, in test_bar
assert 1 == 2
AssertionError

======================================================================
FAIL: test_foo (test_good.TestFoo)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/scratch/jlee/nose_bug_1/test_good.py", line 6, in test_foo
assert 1 == 2
AssertionError

----------------------------------------------------------------------
Ran 2 tests in 0.002s

FAILED (failures=2)

Got:

Doctest: test_bad.TestFoo._test_rhubarb ... ok

----------------------------------------------------------------------
Ran 1 test in 0.005s

OK

The presence of the doctest in the test method stops all other test methods
in the class from being run.

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

http://python-nose.googlecode.com/svn/branches/0.10.0-stable/ within a
smidgen of HEAD (not sure exactly what revision since external SVN is
firewalled off where I am right now). Ubuntu Linux.

Please provide any additional information below.

The reason for this failure is that plugin doctests makes use of plugin
method .makeTest() . That method is generative, which means that any tests
it yields are added to a suite containing those tests plus all other
plugins' .makeTest() tests. However, nose implements its default
.makeTest() logic as a special logic inside
nose.loader.TestLoader.makeTest(), rather than as a plugin. So any plugin
.makeTest() output will clobber tests discovered by the special .makeTest()
logic, rather than adding to them.

Would a patch be welcome that combines the plugin .makeTest() tests with
the default tests? I'm not certain that that won't break other things, but
it looks right at a glance. I can see two obvious approaches:

1. Follow the approach of nose.loader.TestLoader.loadTestsFromTestClass(),
adding the plugin results to the results from the special default logic.

2. Try to move the special logic into a plugin.

I guess 1. is both easier and more sensible at this stage in the release cycle.

Google Code Info:
Issue #: 84
Author: j...@pobox.com
Created On: 2007-08-31T16:17:33.000Z
Closed On: 2007-09-10T19:50:28.000Z