Created
October 13, 2011 08:48
-
-
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.
This file contains hidden or 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
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