On Mon, 1 Jul 2019, Bruno Oliveira wrote:
On Mon, Jul 1, 2019 at 8:17 AM Chris Dent <cd...@anticdent.org> wrote:
Is Gabbi + pytest a plugin? If so, you could store the config object during
pytest_configure to reuse later:

Thanks for the quick response.

It's sort of a plugin. It uses plugin mechanisms to manage the
collection process and manage fixtures that are scoped over a
sequence of tests (instead of just one test).

The issue is that in the deployed tests already using gabbi,
there is no conftest.py nor python test file that is fully
"pytest aware" from which to load the plugin. Instead the test
file calls a function which itself loads pytest and then loads
the plugin:

    import pytest
    pluginmanager = pytest.config.pluginmanager
    pluginmanager.import_plugin('gabbi.pytester')

Messing about just now I see that I've got access to a metafunc and
it has a `config` so this seems to be working:

    if metafunc:
        pluginmanager = metafunc.config.pluginmanager
    else:
        import pytest
        pluginmanager = pytest.config.pluginmanager

(There are older calling scenarios where metafunc will be None.)

Is this a suitable workaround or am I opening myself up for future
trouble by doing this?

Ideally, I would make gabbi+pytest be a proper plugin, but resources
for doing that work have been tight of late and it would mean a
major version bump which I'm reluctant to do until I have solutions
to other large issues in mind.

--
Chris Dent                       ٩◔̯◔۶           https://anticdent.org/
freenode: cdent
_______________________________________________
pytest-dev mailing list
pytest-dev@python.org
https://mail.python.org/mailman/listinfo/pytest-dev

Reply via email to