Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

open_text deprecation warning #21

Open
quadespresso opened this issue Dec 16, 2023 · 2 comments
Open

open_text deprecation warning #21

quadespresso opened this issue Dec 16, 2023 · 2 comments
Labels
bug Something isn't working fix implemented A fix has been implemented, the issue will soon be resolved

Comments

@quadespresso
Copy link

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:

  1. Go to '...'
  2. Click on '....'
  3. Scroll down to '....'
  4. 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.

@mmb-davidsmith
Copy link

I can confirm I'm seeing the same behaviour in pytest as well.

@mrmaxguns
Copy link
Owner

mrmaxguns commented Apr 9, 2024

Yep. Docs say it's deprecated starting with 3.11. Will update that

@mrmaxguns mrmaxguns added bug Something isn't working fix implemented A fix has been implemented, the issue will soon be resolved labels Apr 9, 2024
@mrmaxguns mrmaxguns mentioned this issue Apr 12, 2024
Merged
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working fix implemented A fix has been implemented, the issue will soon be resolved
Projects
None yet
Development

No branches or pull requests

3 participants