Skip to content

Refactor deprecated unittest aliases for Python 3.11 compatibility. #51

New issue

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

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

Already on GitHub? # to your account

Merged
merged 1 commit into from
Aug 13, 2022
Merged

Refactor deprecated unittest aliases for Python 3.11 compatibility. #51

merged 1 commit into from
Aug 13, 2022

Conversation

tirkarthi
Copy link
Contributor

@tirkarthi tirkarthi commented Oct 10, 2021

Use assertRaisesRegex in Python 3 and when present instead of deprecated alias assertRaisesRegexp which is present only in Python 2.

Ref : python/cpython#28268

Fixes below warning :

pytest                 
============================== test session starts ===============================
platform linux -- Python 3.8.0, pytest-6.1.1, py-1.9.0, pluggy-0.13.1
rootdir: /root/python-path-specification
plugins: django-3.9.0, forked-1.1.3, nose2pytest-1.0.8, mock-1.11.1, env-0.6.2, hypothesis-5.20.2, xdist-1.34.0, aiohttp-0.3.0, timeout-1.3.4, cov-2.8.1, pythonpath-0.7.3
collected 54 items                                                               

pathspec/tests/test_gitwildmatch.py ........................s.s.....       [ 59%]
pathspec/tests/test_pathspec.py ..........                                 [ 77%]
pathspec/tests/test_util.py ............                                   [100%]

================================ warnings summary ================================
pathspec/tests/test_gitwildmatch.py::GitWildMatchTest::test_09_single_escape_fail
pathspec/tests/test_gitwildmatch.py::GitWildMatchTest::test_09_single_exclamation_mark_fail
  /root/python-path-specification/pathspec/tests/test_gitwildmatch.py:546: DeprecationWarning: Please use assertRaisesRegex instead.
    with self.assertRaisesRegexp(GitWildMatchPatternError, expected_message_pattern):

-- Docs: https://docs.pytest.org/en/stable/warnings.html

Copy link

@hroncok hroncok left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This fixes the tests in Fedora on Python 3.11.0a2.

@cpburnz cpburnz merged commit 365ffb0 into cpburnz:master Aug 13, 2022
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants