[TIP] How to use same pytest hook at module and function scopes?
Bruno Oliveira
nicoddemus at gmail.com
Wed Feb 8 11:42:44 PST 2017
On Wed, Feb 8, 2017 at 5:36 PM arun kali raja <arunsep886 at gmail.com> wrote:
>
> Each of the test.py has its own common_configuration function definition
> and TCs..(test.py won't have any class def)
> 😊
>
> My Conftest.py will be in BaseFolder/
>
> So if these two fixtures would go into the conftest.py can they still call
> the common_configuration function.?
>
You can use the "request" fixture to obtain the module object and then call
the common_configuration from there:
@pytest.fixture(scope='module')
def module_config(request):
configurationBackup
request.module.common_configuration()
yield
configurationBackup.finalize
"request.module" here will be each "test.py" module.
Cheers,
Bruno.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.idyll.org/pipermail/testing-in-python/attachments/20170208/9a877151/attachment-0001.htm>
More information about the testing-in-python
mailing list