[pytest-dev] (Help) How to replace __multicall__ with hookwrapper?

Ernesto D. Luzon Jr. edluzonjr at gmail.com
Wed Sep 23 16:21:56 CEST 2015


Hi Holger,

Thanks a lot!
That worked. Now I am no longer getting 'deprecated __multicall__' warnings
from pytest 2.8.

Many thanks,
Ernesto D. Luzon Jr.

On Wed, Sep 23, 2015 at 11:00 AM, <pytest-dev-request at python.org> wrote:

> Send pytest-dev mailing list submissions to
>         pytest-dev at python.org
>
> To subscribe or unsubscribe via the World Wide Web, visit
>         https://mail.python.org/mailman/listinfo/pytest-dev
> or, via email, send a message with subject or body 'help' to
>         pytest-dev-request at python.org
>
> You can reach the person managing the list at
>         pytest-dev-owner at python.org
>
> When replying, please edit your Subject line so it is more specific
> than "Re: Contents of pytest-dev digest..."
>
>
> Today's Topics:
>
>    1. (Help) How to replace __multicall__ with hookwrapper?
>       (Ernesto D. Luzon Jr.)
>    2. Re: (Help) How to replace __multicall__ with hookwrapper?
>       (holger krekel)
>    3. Re: (Help) How to replace __multicall__ with hookwrapper?
>       (holger krekel)
>
>
> ----------------------------------------------------------------------
>
> Message: 1
> Date: Tue, 22 Sep 2015 20:27:06 +0100
> From: "Ernesto D. Luzon Jr." <edluzonjr at gmail.com>
> To: pytest-dev at python.org
> Subject: [pytest-dev] (Help) How to replace __multicall__ with
>         hookwrapper?
> Message-ID:
>         <
> CAEpTN6DN-vrKHhAq7oYkp9Wjyvhc7g4pV-WsV5hqa2yzwcYv3Q at mail.gmail.com>
> Content-Type: text/plain; charset="utf-8"
>
> Hi All,
>
> I have code below that is based from the snippet provided by Holger:
>
> http://stackoverflow.com/questions/10754970/in-which-py-test-callout-can-i-find-both-item-and-report-data
>
> def pytest_runtest_makereport(item, call, __multicall__):
>     rep = __multicall__.execute()
>     setattr(item, "rep_" + rep.when, rep)
>     return rep
>
> Now, I'm struggling how to use hookwrapper instead of __multicall__.
> I'd really appreciate if someone can help, thanks!
>
> Many thanks,
> Ernesto D. Luzon Jr.
> -------------- next part --------------
> An HTML attachment was scrubbed...
> URL: <
> http://mail.python.org/pipermail/pytest-dev/attachments/20150922/233d63f0/attachment-0001.html
> >
>
> ------------------------------
>
> Message: 2
> Date: Tue, 22 Sep 2015 19:31:31 +0000
> From: holger krekel <holger at merlinux.eu>
> To: "Ernesto D. Luzon Jr." <edluzonjr at gmail.com>
> Cc: pytest-dev at python.org
> Subject: Re: [pytest-dev] (Help) How to replace __multicall__ with
>         hookwrapper?
> Message-ID: <20150922193131.GW26059 at merlinux.eu>
> Content-Type: text/plain; charset=us-ascii
>
> On Tue, Sep 22, 2015 at 20:27 +0100, Ernesto D. Luzon Jr. wrote:
> > Hi All,
> >
> > I have code below that is based from the snippet provided by Holger:
> >
> http://stackoverflow.com/questions/10754970/in-which-py-test-callout-can-i-find-both-item-and-report-data
> >
> > def pytest_runtest_makereport(item, call, __multicall__):
> >     rep = __multicall__.execute()
> >     setattr(item, "rep_" + rep.when, rep)
> >     return rep
> >
> > Now, I'm struggling how to use hookwrapper instead of __multicall__.
> > I'd really appreciate if someone can help, thanks!
>
> did you look at:
>
>
> https://pytest.org/latest/writing_plugins.html#hookwrapper-executing-around-other-hooks
>
> ?
>
> Your above code should look like this:
>
>     @pytest.hookwrapper
>     def pytest_runtest_makereport(item, call):
>          outcome = yield
>          rep = outcome.get_result()
>          setattr(item, "rep_" + rep.when, rep)
>          return rep
>
> best,
> holger
>
>
> > Many thanks,
> > Ernesto D. Luzon Jr.
>
> > _______________________________________________
> > pytest-dev mailing list
> > pytest-dev at python.org
> > https://mail.python.org/mailman/listinfo/pytest-dev
>
>
> --
> about me:    http://holgerkrekel.net/about-me/
> contracting: http://merlinux.eu
>
>
> ------------------------------
>
> Message: 3
> Date: Tue, 22 Sep 2015 19:44:07 +0000
> From: holger krekel <holger at merlinux.eu>
> To: holger krekel <holger at merlinux.eu>, "Ernesto D. Luzon Jr."
>         <edluzonjr at gmail.com>, pytest-dev at python.org
> Subject: Re: [pytest-dev] (Help) How to replace __multicall__ with
>         hookwrapper?
> Message-ID: <20150922194407.GX26059 at merlinux.eu>
> Content-Type: text/plain; charset=us-ascii
>
> On Tue, Sep 22, 2015 at 19:31 +0000, holger krekel wrote:
> > On Tue, Sep 22, 2015 at 20:27 +0100, Ernesto D. Luzon Jr. wrote:
> > > Hi All,
> > >
> > > I have code below that is based from the snippet provided by Holger:
> > >
> http://stackoverflow.com/questions/10754970/in-which-py-test-callout-can-i-find-both-item-and-report-data
> > >
> > > def pytest_runtest_makereport(item, call, __multicall__):
> > >     rep = __multicall__.execute()
> > >     setattr(item, "rep_" + rep.when, rep)
> > >     return rep
> > >
> > > Now, I'm struggling how to use hookwrapper instead of __multicall__.
> > > I'd really appreciate if someone can help, thanks!
> >
> > did you look at:
> >
> >
> https://pytest.org/latest/writing_plugins.html#hookwrapper-executing-around-other-hooks
> >
> > ?
> >
> > Your above code should look like this:
> >
> >     @pytest.hookwrapper
>
> This should rather read @pytest.hookimpl(hookwrapper=True) like stated in
> the documentation.
>
> holger
>
> >     def pytest_runtest_makereport(item, call):
> >          outcome = yield
> >          rep = outcome.get_result()
> >          setattr(item, "rep_" + rep.when, rep)
> >          return rep
> >
> > best,
> > holger
> >
> >
> > > Many thanks,
> > > Ernesto D. Luzon Jr.
> >
> > > _______________________________________________
> > > pytest-dev mailing list
> > > pytest-dev at python.org
> > > https://mail.python.org/mailman/listinfo/pytest-dev
> >
> >
> > --
> > about me:    http://holgerkrekel.net/about-me/
> > contracting: http://merlinux.eu
> > _______________________________________________
> > pytest-dev mailing list
> > pytest-dev at python.org
> > https://mail.python.org/mailman/listinfo/pytest-dev
> >
>
> --
> about me:    http://holgerkrekel.net/about-me/
> contracting: http://merlinux.eu
>
>
> ------------------------------
>
> Subject: Digest Footer
>
> _______________________________________________
> pytest-dev mailing list
> pytest-dev at python.org
> https://mail.python.org/mailman/listinfo/pytest-dev
>
>
> ------------------------------
>
> End of pytest-dev Digest, Vol 34, Issue 16
> ******************************************
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/pytest-dev/attachments/20150923/3269919e/attachment.html>


More information about the pytest-dev mailing list