Created
February 8, 2013 19:26
-
-
Save carljm/4741316 to your computer and use it in GitHub Desktop.
writing a py.test fixture that can take params from the test
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@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