nose-devs / nose

nose is nicer testing for python
http://readthedocs.org/docs/nose/en/latest/
1.36k stars 394 forks source link

problem with countTestCases() if suite contains generator tests #122

Open jpellerin opened 12 years ago

jpellerin commented 12 years ago

What steps will reproduce the problem?

  1. Create ContextSuite
  2. Add test case from generator
  3. call countTestCases()
  4. call run()

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

I expect that I could run tests from context suite. Instead I got empty suite. It happens because nose.case.FunctionTestCase call countTestCases() from unittest.TestCase. And unittest.TestCase call field _tests each time. But FunctionTestCase can produce tests from generator only once.

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

Please provide any additional information below.

Google Code Info: Issue #: 383 Author: Tuzov...@gmail.com Created On: 2010-12-06T16:17:25.000Z Closed On:

jpellerin commented 12 years ago

For what it's worth, I had this problem while trying to set parameters for my progress bar in nose-progressive. I ended up monkeypatching loadTestsFromName in prepareTestLoader() to capture the parameters that led to the creation of the generator. I could then create a duplicate generator which I could exhaust with impunity.

https://github.com/erikrose/nose-progressive/blob/11bc55efe0fbd2b30b02a1914f22326f74da2985/noseprogressive/plugin.py#L47

Google Code Info: Author: grinche...@gmail.com Created On: 2011-02-21T21:49:23.000Z