Hi,

   I am not sure whether I am sending my query to right mailing list or
not, however, pls. redirect me if my query contradicts with the purpose of
this mailing list.

*Query:*

 I have total 5 independent pytest plugins, however I would like to invoke
them in a right order.  I tried ‘pytest.hookimpl(tryfirst=true) and
pytest.hookimpl(trylast=true), however I don’t know how to align it in
order if I have more than 2 plugins. I tried the same, however it is not
being invoked in order.

===========================

Can someone please provide inputs in this regard?

myplugin1.py

===========

    @pytest.hookimpl(tryfirst=True)

    def pytest_runtest_setup(self, item):

          <>

    @pytest.hookimpl(tryfirst=True)

    def pytest_runtest_teardown(self, item, nextitem):

         <>

myplugin2.py

===========

    @pytest.hookimpl(trylast=True)

    def pytest_runtest_setup(self, item):

        <>

    @pytest.hookimpl(trylast=True)

    def pytest_runtest_teardown(self, item, nextitem):

        <>

myplugin3.py

===========

    @pytest.hookimpl(trylast=True)

    def pytest_runtest_setup(self, item):

         <>

    @pytest.hookimpl(trylast=True)

    def pytest_runtest_teardown(self, item, nextitem):

           <>

myplugin4.py

===========

    @pytest.hookimpl(trylast=True)

    def pytest_runtest_setup(self, item):

       <>

    @pytest.hookimpl(trylast=True)

    def pytest_runtest_teardown(self, item, nextitem):

        <>

myplugin5.py

===========

    @pytest.hookimpl(trylast=True)

    def pytest_runtest_setup(self, item):

         <>

    @pytest.hookimpl(trylast=True)

    def pytest_runtest_teardown(self, item, nextitem):

          <>

Here is <snip> of my pytest.main()…

    addplugins = [myplugin1,myplugin2,myplugin3,myplugin4,myplugin5]

    #  Here we go:

    if not sys.argv[1:]:

        pytest_argv = ["-h"]

    else:

        pytest_argv = sys.argv[1:]

    pyres = pytest.main(pytest_argv,

                        plugins=addplugins)
_______________________________________________
pytest-dev mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pytest-dev

Reply via email to