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
diff --git a/utils/testgen.py b/utils/testgen.py | |
index 096410d..c794b29 100644 | |
--- a/utils/testgen.py | |
+++ b/utils/testgen.py | |
@@ -222,7 +222,7 @@ def provider_by_type(metafunc, provider_types, *fields, **options): | |
idlist = [] | |
special_args = ('provider_key', 'provider_data', 'provider_crud', | |
- 'provider_mgmt', 'provider_type') | |
+ 'provider_mgmt', 'provider_type', 'provider_setup') | |
# Hook on special attrs if requested | |
for argname in special_args: | |
if argname in metafunc.fixturenames and argname not in argnames: | |
@@ -270,11 +270,20 @@ def provider_by_type(metafunc, provider_types, *fields, **options): | |
mgmt = provider_factory(provider) | |
+ def provider_setup(): | |
+ logger.info('the fixture ran!') | |
+ return 'provider_setup' | |
+ provider_setup = pytest.fixture()(provider_setup) | |
+ | |
values = [] | |
- special_args_map = dict(zip(special_args, (provider, data, crud, mgmt, prov_type))) | |
+ special_args_map = dict(zip(special_args, (provider, data, crud, mgmt, prov_type, | |
+ provider_setup))) | |
for arg in argnames: | |
if arg in special_args_map: | |
values.append(special_args_map[arg]) | |
+ if arg == 'provider_setup': | |
+ metafunc.fixturenames.append(arg) | |
+ print metafunc.fixturenames | |
elif arg in data_values: | |
values.append(data_values[arg]) |
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 | |
from utils import testgen | |
pytest_generate_tests = testgen.generate(testgen.infra_providers) | |
# def pytest_generate_tests(metafunc): | |
# ret = testgen.infra_providers(metafunc) | |
# print ret | |
# return ret | |
@pytest.fixture(scope="module") | |
def fixture(): | |
pass | |
def test_gen(provider_setup): | |
print 'provider setup', provider_setup |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment