bobber6467 / python-nose

Automatically exported from code.google.com/p/python-nose
0 stars 0 forks source link

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

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 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.

Original issue reported on code.google.com by Tuzov...@gmail.com on 6 Dec 2010 at 4:17

GoogleCodeExporter commented 8 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/11bc55efe0fbd2b30b02a1914f2232
6f74da2985/noseprogressive/plugin.py#L47

Original comment by grinche...@gmail.com on 21 Feb 2011 at 9:49