Skip to content

Instantly share code, notes, and snippets.

@carljm
Created February 8, 2013 19:26
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 carljm/4741316 to your computer and use it in GitHub Desktop.
Save carljm/4741316 to your computer and use it in GitHub Desktop.
writing a py.test fixture that can take params from the test
@pytest.fixture
def template(request):
if 'param' in request.fixturenames:
param = request.getfuncargvalue('param')
else:
param = 'default'
# return something based on param
@pytest.mark.parametrize('param', ['one', 'two'])
def test_something(template, param):
# test goes here
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment