joalla / discogs_client

Continuation of the "Official Python Client for the Discogs API"
https://python3-discogs-client.readthedocs.io
Other
310 stars 50 forks source link

Test failures on Python 3.11 #107

Closed mgorny closed 1 week ago

mgorny commented 2 years ago

Two tests are failing with Python 3.11.0b3. I think it's due to changed enum repr:

========================================================= test session starts =========================================================
platform linux -- Python 3.11.0b3, pytest-7.1.2, pluggy-1.0.0
rootdir: /tmp/discogs_client
collected 45 items                                                                                                                    

discogs_client/tests/test_core.py ........                                                                                      [ 17%]
discogs_client/tests/test_fetchers.py ..                                                                                        [ 22%]
discogs_client/tests/test_models.py ............................                                                                [ 84%]
discogs_client/tests/test_utils.py .F...F.                                                                                      [100%]

============================================================== FAILURES ===============================================================
____________________________________________________ UtilsTestCase.test_condition _____________________________________________________

self = <discogs_client.tests.test_utils.UtilsTestCase testMethod=test_condition>

    def test_condition(self):
        self.assertRaises(TypeError, lambda: utils.Condition())
>       self.assertEqual(utils.Condition.MINT, 'Mint (M)')
E       AssertionError: <Condition.MINT: 'Mint (M)'> != 'Mint (M)'

discogs_client/tests/test_utils.py:66: AssertionError
______________________________________________________ UtilsTestCase.test_status ______________________________________________________

self = <discogs_client.tests.test_utils.UtilsTestCase testMethod=test_status>

    def test_status(self):
        self.assertRaises(TypeError, lambda: utils.Status())
>       self.assertEqual(utils.Status.DRAFT, 'Draft')
E       AssertionError: <Status.DRAFT: 'Draft'> != 'Draft'

discogs_client/tests/test_utils.py:71: AssertionError
========================================================== warnings summary ===========================================================
discogs_client/utils.py:102
  /tmp/discogs_client/discogs_client/utils.py:102: DeprecationWarning: In 3.13 classes created inside an enum will not become a member.  Use the `member` decorator to keep the current behavior.
    class By(Enum):

discogs_client/utils.py:123
  /tmp/discogs_client/discogs_client/utils.py:123: DeprecationWarning: In 3.13 classes created inside an enum will not become a member.  Use the `member` decorator to keep the current behavior.
    class Order(Enum):

.venv/lib/python3.11/site-packages/certifi/core.py:36
  /tmp/discogs_client/.venv/lib/python3.11/site-packages/certifi/core.py:36: DeprecationWarning: path is deprecated. Use files() instead. Refer to https://importlib-resources.readthedocs.io/en/latest/using.html#migrating-from-legacy for migration advice.
    _CACERT_CTX = get_path("certifi", "cacert.pem")

-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html
======================================================= short test summary info =======================================================
FAILED discogs_client/tests/test_utils.py::UtilsTestCase::test_condition - AssertionError: <Condition.MINT: 'Mint (M)'> != 'Mint (M)'
FAILED discogs_client/tests/test_utils.py::UtilsTestCase::test_status - AssertionError: <Status.DRAFT: 'Draft'> != 'Draft'
============================================== 2 failed, 43 passed, 3 warnings in 0.38s ===============================================
AnssiAhola commented 2 years ago

Hey @mgorny

Technically we don't currently support python versions above 3.9, but having tested 3.10 here #108 It seems to work fine.

Since 3.11 isn't released yet, I wouldn't look too much into this myself, at this point at least.

If you want to implement a fix for this, feel free to submit a PR.

Cheers! -Anssi

mgorny commented 2 years ago

Since 3.11 isn't released yet, I wouldn't look too much into this myself, at this point at least.

It's past feature freeze already, so right now it's the best time to fix packages so they're ready when the time comes ;-).

If you want to implement a fix for this, feel free to submit a PR.

Will do that shortly.

By the way, I've noticed that the Sort enum is a bit weird here, as normally it doesn't return enum values but the underlying string:

>>> discogs_client.utils.Sort.By.ARTIST
<<< 'artist'
>>> discogs_client.utils.Sort.By.value.ARTIST
<<< <By.ARTIST: 'artist'>

I don't know if this has any practical implications but it certainly looks suspicious.

JOJ0 commented 1 week ago

Fixed in 3.7.1

mgorny commented 1 week ago

Thank you!