Skip to content

Instantly share code, notes, and snippets.

@rossant
Created September 29, 2015 19:06
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rossant/87a2c147f94f8729ac96 to your computer and use it in GitHub Desktop.
Save rossant/87a2c147f94f8729ac96 to your computer and use it in GitHub Desktop.
Fixture for IPython.parallel and pytest
import os
from pytest import yield_fixture
@yield_fixture(scope='module')
def ipy_client():
def iptest_stdstreams_fileno():
return os.open(os.devnull, os.O_WRONLY)
# OMG-THIS-IS-UGLY-HACK: monkey-patch this global object to avoid
# using the nose iptest extension (we're using pytest).
# See https://github.com/ipython/ipython/blob/master/IPython/testing/iptest.py#L317-L319 # noqa
from ipyparallel import Client
import ipyparallel.tests
ipyparallel.tests.nose.iptest_stdstreams_fileno = iptest_stdstreams_fileno
# Start two engines engine (one is launched by setup()).
ipyparallel.tests.setup()
ipyparallel.tests.add_engines(1)
yield Client(profile='iptest')
ipyparallel.tests.teardown()
def test_client(ipy_client):
print(ipy_client.ids)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment