-
-
Save elizabethlin/7754f0324b8f7b1c7388 to your computer and use it in GitHub Desktop.
now we're getting:
test_example.py:34: TestExample.test_one[std] FAILED
test_example.py:38: TestExample.test_two[std] FAILED
test_example.py:34: TestExample.test_one[typeA] FAILED
test_example.py:38: TestExample.test_two[typeA] FAILED
test_example.py:34: TestExample.test_one[typeB] FAILED
test_example.py:38: TestExample.test_two[typeB] FAILED
te…
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
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, | |
scope='session') | |
@pytest.fixture(scope='session') | |
def generatedfix(request): | |
if request.param == 'typeA': | |
return 'typeA' | |
elif request.param == 'typeB': | |
return 'typeB' | |
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
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') | |
@pytest.fixture(scope='session') | |
def fixA(request): | |
if request.param == 'std': | |
return request.getfuncargvalue("std") | |
else: | |
return virt(pytest_myplugin.generatedfix(request)) | |
@pytest.fixture(scope='session') | |
def std(request): | |
return "std" | |
@pytest.fixture(scope='session') | |
def virt(request, generatedfix): | |
return "virt-{0}".format(generatedfix) | |
class TestExample(object): | |
def test_one(self, fixA): | |
print fixA | |
assert(0) | |
def test_two(self, fixA): | |
print fixA | |
assert(0) | |
def test_three(self, std): | |
print std | |
assert(0) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment