[TIP] How to use same pytest hook at module and function scopes?
arun kali raja
arunsep886 at gmail.com
Wed Feb 8 12:37:15 PST 2017
Thanks a lot Bruno,
If thatz the case can i have one module level fixture which calls the
configurationBackup method and for the function level backup instead of
writing another fixture can i use the pytest hook
pytest_runtest_call to call the configurationBackup method.. ?
Which is the correct and advantageous approach?
Arun kali raja.B
On 09-Feb-2017 1:12 AM, "Bruno Oliveira" <nicoddemus at gmail.com> wrote:
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:
"request.module" here will be each "test.py" module.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the testing-in-python