bobber6467 / python-nose

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

Using multiprocessing results in makeTest() being called several times for the same test. #406

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. Create a plugin that redefines makeTest, have it print some debug info, 
2. Run a dummy test case with multiprocessing

example:

#!/usr/bin/python
import os
import nose
from nose.plugins import Plugin

class MakePlugin( Plugin ):

    enabled = True
    name = "MakePlugin"
    score = 100

    def options(self, parser, env):
        pass

    def configure(self, options, conf):
        pass

    def makeTest( self, obj, parent ):
        print 'make test, parent process:', os.getppid(), 'process id:', os.getpid(), 'self:', self, 'obj:', obj, 'parent:', parent
        return None

if __name__ == '__main__':
    nose.main(addplugins=[MakePlugin()])

def testEcho():
    print "test", os.getpid()

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

The test is run once, but the makeTest method of the plugin is called several 
times for the same test:

./testM.py testM -s --processes=2
make test, parent process: 18735 process id: 8487 self: <__main__.MakePlugin 
object at 0xc92290> obj: <function testEcho at 0x189ae60> parent: <module 
'testM' from '/XXXXX/testM.py'>
make test, parent process: 8487 process id: 8532 self: <__main__.MakePlugin 
object at 0xc92290> obj: <function testEcho at 0x189ae60> parent: <module 
'testM' from '/XXXXX/testM.py'>
test 8532
.
----------------------------------------------------------------------
Ran 1 test in 0.011s

OK

I would expect the makeTest to be called only once. In practice, I have a 
plugin that generates several tests from a given input tests. When using 
multiprocessing, it generates the same tests several times since makeTest is 
called several times on the same input test.

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

Tested on 0.11.1, will test on 1.0.0

Please provide any additional information below.

Original issue reported on code.google.com by antoine....@gmail.com on 23 Mar 2011 at 10:19

GoogleCodeExporter commented 8 years ago
Just tried with nose 1.0.0 and the bug seems gone. Sorry for the noise!

Original comment by antoine....@gmail.com on 24 Mar 2011 at 3:44

GoogleCodeExporter commented 8 years ago
thanks for the bug report, glad it's working.

Original comment by kumar.mcmillan on 24 Mar 2011 at 2:35