You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Since #7 .fixture.create() can be called in conftest.py to get fixture names which can be reused in test functions.
This does not work of one of the base layers of the requested layer is used in another package, too because then the fixture function of the base layer is not found there. (Technical detail: the baseid of the fixture function does not match with the nodeid of the function under test. If the fixture function is not created using an explicit call to .fixture.create() the baseid is '' which matches.)
Possible solution:
FIXTURE_CODE_TEMPLATE="""@pytest.fixture('{scope}')def {name}({base}): return locals()['{base}']"""defcreate_fixture(name, layer, scope='function'):
"""Create a ficxture for a layer."""base=gocept.pytestlayer.fixture.get_fixture_name(layer, scope)
code=FIXTURE_CODE_TEMPLATE.format(**locals())
ns= {}
exec(code, {'pytest': pytest}, ns)
returnns
Write down warning about this approach: If a layer is not used on a test case it will not be found. Maybe .fixture.create() can be adapted so that my new function is not necessary.
The text was updated successfully, but these errors were encountered:
transferred from bitbucket:
Since #7 .fixture.create() can be called in conftest.py to get fixture names which can be reused in test functions.
This does not work of one of the base layers of the requested layer is used in another package, too because then the fixture function of the base layer is not found there. (Technical detail: the baseid of the fixture function does not match with the nodeid of the function under test. If the fixture function is not created using an explicit call to .fixture.create() the baseid is '' which matches.)
Possible solution:
Example call:
Tasks:
The text was updated successfully, but these errors were encountered: