[py-dev] adding env option to xspec (initialy posted to [execnet-dev])

holger krekel holger at merlinux.eu
Fri Jun 25 16:41:06 CEST 2010


Hi Jakub, 

On Fri, Jun 25, 2010 at 15:10 +0100, Jakub Gustak wrote:
> > I suggest to use
> >
> >    popen//env:NAME=value
> >
> > as syntax.   That being said i am not totally opposed to adding
> > it directly to execnet.  Maybe other people here on the list also
> > have comments ...
> ...
> Moving this topic to py-dev list in this case.
> 
> I prepared a patch, please review.
> 
> What I don't like about it is using XSspec.__dict__ because
> env:NAME=VALUE requires a iteration through XSpec attributes:
> 
> +    def env(self):
> +        return [(env.lstrip('env:'), value)
> +                    for env, value in  self.gateway.spec.__dict__.iteritems()
> +                    if env.startswith('env:')]
> 
> I believe a small extension to XSpec API would be nice. Any other ideas?

I think this is bearable as xspecs have very few key-value pairs. 
You could use env[4:] instead of lstrip() to optimize though :) 

One other bit: could you try to rework your patch so that it transfers
the environment variables in the "slaveinput" dictionary? 
This is also processable from pytest_configure and produces a 
smaller patch i guess. 

best,

holger



More information about the Pytest-dev mailing list