← 返回首页
bpo-5846: Deprecate obsolete methods in `unittest` by erlend-aasland · Pull Request #28299 · python/cpython · GitHub
Skip to content

Navigation Menu

Toggle navigation
Sign in
Appearance settings
Search or jump to...

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Include my email address so I can be contacted

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
Resetting focus

bpo-5846: Deprecate obsolete methods in unittest#28299

Merged
ambv merged 10 commits into
python:mainfrom
erlend-aasland:fix-issue-5846
Sep 15, 2021
Merged

bpo-5846: Deprecate obsolete methods in unittest#28299
ambv merged 10 commits into
python:mainfrom
erlend-aasland:fix-issue-5846

Conversation

erlend-aasland commented Sep 12, 2021
edited by bedevere-bot
Loading

Copy link
Copy Markdown
Contributor
  • unittest.findTestCases
  • unittest.makeSuite
  • unittest.getTestCaseNames

Scheduled for removal in Python 3.13

https://bugs.python.org/issue5846

…tTestCaseNames in unittest Scheduled for removal in Python 3.13

Copy link
Copy Markdown
Contributor Author

Replaces GH-20400.

Copy link
Copy Markdown
Member

I am working on a patch which gets rid of uses of obsolete functions.

erlend-aasland commented Sep 12, 2021
edited
Loading

Copy link
Copy Markdown
Contributor Author

I had to adapt test_support, since __module__ is now unittest instead of unittest.loader for these three functions.

serhiy-storchaka left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality Hide comment

Are all tests warning-free?

If these functions are not used in unittest tests, add special tests, catch DeprecationWarning and check the filename attribute (to ensure that the stacklevel is correct).

Comment thread Doc/whatsnew/3.11.rst Outdated Show resolved Hide resolved
Comment thread Lib/test/test_support.py Outdated Show resolved Hide resolved
Comment thread Lib/unittest/__init__.py
_TextTestResult = TextTestResult

from .loader import (
makeSuite as _makeSuite,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality Hide comment

Why not add deprecations when they are defined?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality Hide comment

IIUC, it is the "shortcuts" that are deprecated, not the methods themselves. Should I deprecate the undocumented unittest.TestLoader.makeSuite and unittest.TestLoader.findTestCases as well?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality Hide comment

There are no unittest.TestLoader.makeSuite and unittest.TestLoader.findTestCases.

erlend-aasland Sep 14, 2021
edited
Loading

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality Hide comment

Sorry, I meant unittest.loader, not unittest.TestLoader:

>>> import unittest >>> unittest.loader.makeSuite <function makeSuite at 0x10be0e2a0> >>> unittest.loader.findTestCases <function findTestCases at 0x10be0e340> >>>

ambv merged commit ff6d2cc into python:main Sep 15, 2021
erlend-aasland deleted the fix-issue-5846 branch September 15, 2021 18:34

Copy link
Copy Markdown
Contributor Author

Thanks for reviewing and merging, @serhiy-storchaka and @ambv!

lazka added a commit to lazka/distutils that referenced this pull request Dec 27, 2021
See python/cpython#28299 loadTestsFromTestCase() is available since Python 2.7 at least.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants

Footer

© 2026 GitHub, Inc.