[pytest-dev] pytest 5.0.0 and pluginmanager
Bruno Oliveira
nicoddemus at gmail.com
Mon Jul 1 07:38:43 EDT 2019
Hi Chris,
On Mon, Jul 1, 2019 at 8:17 AM Chris Dent <cdent at anticdent.org> wrote:
>
> That uses the now deprecated `pytest.config` global and I'm
> struggling to determine how best to replace it without having to
> make changes to the calling patterns that would break compatibility
> with existing test installations.
>
Is Gabbi + pytest a plugin? If so, you could store the config object during
pytest_configure to reuse later:
```
_gabbi_pytest_config = None
def pytest_configure(config):
global _gabbi_pytest_config
_gabbi_pytest_config = config
def pytest_unconfigure():
global _gabbi_pytest_config
_gabbi_pytest_config = None
```
This is basically what pytest did to provide the pytest.config global. This
is more elegant if you can register this in a class of course.
If you don't have a proper plugin, it is easy to write a small one even if
only to get that global.
> This is the second implementation of gabbi+pytest. The first one
> used yield tests (for which I gained a strong affection long ago).
> The second was created to be compatible with existing deployed
> tests. Now I find myself needing to adapt things again. If I can
> continue to be compatible that would be great.
>
It should definitely be possible, with minimal effort. Let us know if we
can help further.
Cheers,
Bruno;
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/pytest-dev/attachments/20190701/fd1ce23a/attachment.html>
More information about the pytest-dev
mailing list