Skip to content

Instantly share code, notes, and snippets.

@seandst
Created June 19, 2014 16:44
Show Gist options
  • Save seandst/2b1adb9ad1cd09ea9725 to your computer and use it in GitHub Desktop.
Save seandst/2b1adb9ad1cd09ea9725 to your computer and use it in GitHub Desktop.
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