Hi Meme,

On Wed, Apr 21, 2010 at 22:47 +1000, meme dough wrote:
> > Could you see to implement my above suggestions and see
> > if it still satisfies your use case?
> > (reuse testnodeready, slavedata dict,
> > config<->node relationship on slaves)
> >
> > If i see it right that'd confine changes to the xdist code
> > in which case i'd be willing to release it soon.
> 
> I changed to use slaveready and changed both the slavedata and
> slavereport to be a simple dict.

thanks.
 
> Not sure with the relationships on slaves.  The hooks just access the
> session / slave object to get config / slavedata / slavereport.  Seems
> clear to me atm, but maybe I misunderstood.

Only sessionstart/sessionfinish get a 'session' (node) object while
all other hooks can not easily obtain a session reference.  However, 
almost all hooks receive or can easily get to a 'config' object. 
Therefore i think it's better to stick the slavedata object to 
the config object.  

> I added test which works, but could maybe be better when it fails.
> Wasn't sure how to best make a test of pytest with a hook running on a
> slave fail.
>
> What do you think?
> 
> http://bitbucket.org/memedough/pytest-xdist-slaveready/overview

The test looks fine.  Looking at your patch and at things some more i
wonder if it isn't eventually better to introduce a new hook - even 
if it requires a new py.test release.  Something like: 

    # runs only on the master side 
    def pytest_xdist_configure_node(node):
        node.slaveinput[NAME] = value

    # any hook or test can do the following manipulation
        if hasattr(config, 'slavedata'): # means we are running slave side
            config.slaveinput[NAME]      # access data sent from the master
            config.slaveoutput['result'] = 42  # set slave output

    # runs only on the master side 
    def pytest_xdist_nodedown(node, slaveoutput):
        node.slaveoutput['result'] # access result from slave

I think both internal implementation and usage becomes simpler. 
What do you think? 

When doing the a new py.test release i'd like to look into 
allowing to add per-plugin hooks and systematically name xdist-hooks.

If you'd like to push ahead before i finish this you can just add the 
hooks statically and i patch it out later. 

cheers,
holger
_______________________________________________
py-dev mailing list
py-dev@codespeak.net
http://codespeak.net/mailman/listinfo/py-dev

Reply via email to