Tuesday, May 01, 2018

Pytest warning: How to fix Pytest plugin warnings

If, like most of the guys I know, you use Pytest for testing, you will at some stage run into different warnings when running your tests. Mine for some reason started issuing a warning like this:
pytest_funcarg__cov: declaring fixtures using "pytest_funcarg__" prefix is deprecated and scheduled to be removed in pytest 4.0.  Please remove the prefix and use the @pytest.fixture decorator instead.

Although, this did not stop the test from passing - it simply changed the colour to yellow instead of green to indicate that your tests passed successfully.

In my case, the issue was due to an outdated version of pytest-cov plugin that was installed as part of the original pytest installation. As it turns out, pytest won't upgrade it even when you upgrade your pytest version. So, you are left to not only figure out what the issue is, but how to fix it.

In most cases where similar warnings are shown, it can easily be fixed by first identifying which of the plugins is causing the issue rather than suppressing it; and attempt to upgrade it separately. This should hopefully fix it.

Again, in my case a simple command like this:
pip install --upgrade pytest-cov

helped to fix the issues and returned my test results to green.
Related Posts with Thumbnails