Skip to content

Instantly share code, notes, and snippets.


elizabethlin/ Secret

Last active Dec 17, 2015
What would you like to do?
now we're getting: TestExample.test_one[std] FAILED TestExample.test_two[std] FAILED TestExample.test_one[typeA] FAILED TestExample.test_two[typeA] FAILED TestExample.test_one[typeB] FAILED TestExample.test_two[typeB] FAILED te…
import pytest
def pytest_generate_tests(metafunc):
if 'generatedfix' in metafunc.fixturenames:
# I get the params from a yaml file, simplifying atm
metafunc.parametrize('generatedfix', ['typeA', 'typeB'], indirect=True,
def generatedfix(request):
if request.param == 'typeA':
return 'typeA'
elif request.param == 'typeB':
return 'typeB'
import pytest
import pytest_myplugin
pytest_plugins = ['pytest_myplugin']
def pytest_generate_tests(metafunc):
if 'fixA' in metafunc.fixturenames:
# would grab the yaml file info here
values = ['typeA', 'typeB']
values.insert(0, 'std')
metafunc.parametrize('fixA', values, indirect=True, scope='session')
def fixA(request):
if request.param == 'std':
return request.getfuncargvalue("std")
return virt(pytest_myplugin.generatedfix(request))
def std(request):
return "std"
def virt(request, generatedfix):
return "virt-{0}".format(generatedfix)
class TestExample(object):
def test_one(self, fixA):
print fixA
def test_two(self, fixA):
print fixA
def test_three(self, std):
print std
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment