4

I have a myfun.py file with my functions.
And I have a test_myfun.py file with pytest tests.

When running pytest test_myfun.py, the tests themselves run without errors, but pytest gives warnings.

Any suggestions how to solve these warnings?

=============================== warnings summary ===============================
/home/rene/anaconda3/lib/python3.7/site-packages/html5lib/_trie/_base.py:3
  /home/rene/anaconda3/lib/python3.7/site-packages/html5lib/_trie/_base.py:3: DeprecationWarning: Using or importing the ABCs from 'collections' instead of from 'collections.abc' is deprecated, and in 3.8 it will stop working
    from collections import Mapping

/home/rene/anaconda3/lib/python3.7/site-packages/scrapy/item.py:8
  /home/rene/anaconda3/lib/python3.7/site-packages/scrapy/item.py:8: DeprecationWarning: Using or importing the ABCs from 'collections' instead of from 'collections.abc' is deprecated, and in 3.8 it will stop working
    from collections import MutableMapping

-- Docs: https://docs.pytest.org/en/latest/warnings.html
==================== 11 passed, 2 warnings in 7.47 seconds =====================

Version info:
- Python 3.7.3
- pytest 4.6.2

# packages in environment at /home/rene/anaconda3:
#
# Name                    Version                   Build  Channel
pytest                    4.6.2                    py37_0  
pytest-arraydiff          0.3              py37h39e3cac_0  
pytest-astropy            0.5.0                    py37_0  
pytest-doctestplus        0.3.0                    py37_0  
pytest-openfiles          0.3.2                    py37_0  
pytest-remotedata         0.3.1                    py37_0  
pytest-runner             4.4                        py_0  
3
  • 1
    those packages need to be updated, that's all. They're still compatible, but won't be anymore in 3.8 that's what the message says Commented Jun 21, 2019 at 20:01
  • Thanks, but I have the latest packages installed from Anaconda and still get these warnings. Commented Jun 21, 2019 at 20:16
  • 1
    yes, precisely because the authors didn't fix the warnings yet. When I said "updated" I meant "updated by someone who will fix the code", not someone using "pip" to upgrade, since the upgrade doesn't exist yet. Commented Jun 21, 2019 at 20:17

1 Answer 1

8

You have two options.

1) Upgrade your packages, that is if the most recent versions of html5lib and scrapy have fixed these warnings.

2) Create a pytest.ini file in the root of your repo and give it these contents, which will make pytest ignore the DeprecationWarning

[pytest]
filterwarnings =
    ignore::DeprecationWarning
Sign up to request clarification or add additional context in comments.

2 Comments

I'm interested by the second option (in my case, the most recent version of the package is generating the same warnings). However, isn't setting the ignore::DeprecationWarning option also silences those warnings if there are other deprecations coming from my code? That's what I want to avoid.
@htaidirt you may use ignore:my regexp:DeprecationWarning to filter only DeprecationWarnings that match the regex.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.