Skip to content

Extract the twisted greenlet initialization to a separate function #10

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jan 8, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
language: python
python:
- "2.7"
- "2.6"

install:
- pip install tox
- export TOX_ENV=`tox --listenvs | grep "py${TRAVIS_PYTHON_VERSION/./}" | tr '\n' ','`

script: tox -e $TOX_ENV
19 changes: 14 additions & 5 deletions pytest_twisted/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,19 @@ def inlineCallbacks(fun, *args, **kw):


def pytest_namespace():
return dict(inlineCallbacks=inlineCallbacks, blockon=blockon)
return dict(
inlineCallbacks=inlineCallbacks,
blockon=blockon,
init_twisted_greenlet=init_twisted_greenlet
)


def init_twisted_greenlet():
global gr_twisted
if not gr_twisted:
gr_twisted = greenlet.greenlet(reactor.run)
failure.Failure.cleanFailure = lambda self: None # give me better tracebacks
return gr_twisted


def stop_twisted_greenlet():
Expand All @@ -44,11 +56,8 @@ def stop_twisted_greenlet():

@pytest.fixture(scope="session", autouse=True)
def twisted_greenlet(request):
global gr_twisted
gr_twisted = greenlet.greenlet(reactor.run)
failure.Failure.cleanFailure = lambda self: None # give me better tracebacks
request.addfinalizer(stop_twisted_greenlet)
return gr_twisted
return init_twisted_greenlet()


def _pytest_pyfunc_call(pyfuncitem):
Expand Down
7 changes: 7 additions & 0 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,13 @@ deps=pytest
commands=py.test []
sitepackages=False

[testenv:py26]
deps=pytest<3.3
greenlet
twisted<15.5
commands=py.test []
sitepackages=False

[testenv:py25]
deps=pytest
greenlet
Expand Down