Skip to content

Instantly share code, notes, and snippets.

@jacob414
Created October 13, 2011 08:48
Show Gist options
  • Save jacob414/1283764 to your computer and use it in GitHub Desktop.
Save jacob414/1283764 to your computer and use it in GitHub Desktop.
Minimal example of py.test funcargs where one parameter is static and the other varying.
import py
def pytest_generate_tests(metafunc):
fargs = {}
if 'static' in metafunc.funcargnames:
fargs['static'] = 'stays the same'
if 'different' in metafunc.funcargnames:
for variant in (1,2):
metafunc.addcall(funcargs=dict(different=variant, **fargs))
else:
metafunc.addcall(funcargs=fargs)
def test_funcargs_static(static):
assert static == 'stays the same'
def test_funcargs_different(different):
assert different in (1,2)
def test_funcargs_combo(static, different):
assert static == 'stays the same'
assert different in (1,2)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment