`open_text` deprecation warning
Describe the bug A clear and concise description of what the bug is.
Hit this while running pytest with this module:
../../.venv/lib/python3.11/site-packages/wonderwords/random_word.py:66
../../.venv/lib/python3.11/site-packages/wonderwords/random_word.py:66
../../.venv/lib/python3.11/site-packages/wonderwords/random_word.py:66
../../.venv/lib/python3.11/site-packages/wonderwords/random_word.py:66
/home/jimc/proj/.venv/lib/python3.11/site-packages/wonderwords/random_word.py:66: DeprecationWarning: open_text is deprecated. Use files() instead. Refer to https://importlib-resources.readthedocs.io/en/latest/using.html#migrating-from-legacy for migration advice.
words = pkg_resources.open_text(assets, word_file).readlines()
-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html
To Reproduce Steps to reproduce the behavior:
- Go to '...'
- Click on '....'
- Scroll down to '....'
- See error
Create a simple pytest example such as this:
import pytest
from wonderwords import RandomWord
@pytest.fixture(scope="module")
def random_word_pair():
"""Return a noun/adjective pair of random words"""
w = RandomWord()
noun = w.word(include_categories=["noun"])
adjective = w.word(include_categories=["adjective"])
return noun, adjective
then run it:
❯ pytest simpletest.py
=============================================================================================== test session starts ===============================================================================================
platform linux -- Python 3.11.6, pytest-7.4.3, pluggy-1.3.0
rootdir: /home/jimc/testing
collected 0 items
================================================================================================ warnings summary =================================================================================================
.venv/lib/python3.11/site-packages/wonderwords/random_word.py:66
.venv/lib/python3.11/site-packages/wonderwords/random_word.py:66
.venv/lib/python3.11/site-packages/wonderwords/random_word.py:66
.venv/lib/python3.11/site-packages/wonderwords/random_word.py:66
/home/jimc/testing/.venv/lib/python3.11/site-packages/wonderwords/random_word.py:66: DeprecationWarning: open_text is deprecated. Use files() instead. Refer to https://importlib-resources.readthedocs.io/en/latest/using.html#migrating-from-legacy for migration advice.
words = pkg_resources.open_text(assets, word_file).readlines()
-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html
=============================================================================================== 4 warnings in 0.00s ===============================================================================================
Expected behavior A clear and concise description of what you expected to happen.
No deprecation warnings pertaining to open_text while running pytest.
Screenshots If applicable, add screenshots to help explain your problem.
Desktop (please complete the following information):
- OS: [e.g. iOS]
- Browser [e.g. chrome, safari]
- Version [e.g. 22]
Smartphone (please complete the following information):
- Device: [e.g. iPhone6]
- OS: [e.g. iOS8.1]
- Browser [e.g. stock browser, safari]
- Version [e.g. 22]
Additional context Add any other context about the problem here.
I can confirm I'm seeing the same behaviour in pytest as well.
Yep. Docs say it's deprecated starting with 3.11. Will update that