Re: [py-dev] pytest-twisted 1.0

2012-10-22 Thread holger krekel
Hi Ralf,

On Mon, Oct 22, 2012 at 00:53 +0200, Ralf Schmitt wrote:
 Hi,
 
 I've upload pytest-twisted to pypi [1]. It's a plugin which allows to test
 twisted code with pytest. The code is also available on github [2].
 
 
 [1] http://pypi.python.org/pypi/pytest-twisted
 [2] https://github.com/schmir/pytest-twisted

interesting little plugin.  On a general note, using pytest_configure
is not the best way to setup global state.  It's better to do this::

@pytest.fixture(scope=session, autouse=True):
def setup_twisted_reactor(request):
...
request.addfinalizer(...)

This autouse-fixture (i.e. an automatically active fixture without the
need to use it as a funcarg or declare a usefixtures) will be executed
only in processes which execute tests, so works cleaner with distributed
testing.  The pytest_configure is also called for the xdist-master
process which does not execute or collect tests at all.

If there were multiple reactors / global states you could also use
params to run the whole test suite multiple times with different
reactors - only one reactor / global state instance will be active at
any time. That's not possible when using pytest_configure.

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


Re: [py-dev] pytest-twisted 1.0

2012-10-22 Thread Ralf Schmitt
holger krekel hol...@merlinux.eu writes:


 interesting little plugin.  On a general note, using pytest_configure
 is not the best way to setup global state.  It's better to do this::

 @pytest.fixture(scope=session, autouse=True):
 def setup_twisted_reactor(request):
 ...
 request.addfinalizer(...)

thanks for your comments. I'll try to implement that in the next
version. BTW, an early version of this plugin was once part of pylib :)

-- 
Cheers
Ralf
___
py-dev mailing list
py-dev@codespeak.net
http://codespeak.net/mailman/listinfo/py-dev