Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@seandst
Last active August 29, 2015 14:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save seandst/c3afdceabb088b8814fc to your computer and use it in GitHub Desktop.
Save seandst/c3afdceabb088b8814fc to your computer and use it in GitHub Desktop.
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])
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