Skip to content

Instantly share code, notes, and snippets.

@seandst
Created June 19, 2014 16:44
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Embed
What would you like to do?
import random
import pytest
@pytest.fixture
def random_number(request):
# You can set attrs on the py.test Config object whenever you want
# Here works, as well as any pytest hook that accepts the config arg
request.session.config.random_number = random.randint(0, 10000)
def test_random_number(random_number, request):
# And then they're in the config, which will be passed the the
# subprocess workers
assert request.session.config.random_number
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment