X Tutup
The Wayback Machine - https://web.archive.org/web/20220203074238/https://github.com/python/cpython/pull/28299
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

bpo-5846: Deprecate obsolete methods in unittest #28299

Merged
merged 10 commits into from Sep 15, 2021

Conversation

@erlend-aasland
Copy link
Contributor

@erlend-aasland erlend-aasland commented Sep 12, 2021

  • 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
@erlend-aasland
Copy link
Contributor Author

@erlend-aasland erlend-aasland commented Sep 12, 2021

Replaces GH-20400.

@serhiy-storchaka
Copy link
Member

@serhiy-storchaka serhiy-storchaka commented Sep 12, 2021

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

@erlend-aasland
Copy link
Contributor Author

@erlend-aasland erlend-aasland commented Sep 12, 2021

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

Copy link
Member

@serhiy-storchaka serhiy-storchaka left a 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).

Doc/whatsnew/3.11.rst Outdated Show resolved Hide resolved
Lib/test/test_support.py Outdated Show resolved Hide resolved
@@ -70,6 +70,37 @@ def testMultiply(self):
# deprecated
_TextTestResult = TextTestResult

from .loader import (
makeSuite as _makeSuite,
Copy link
Member

@serhiy-storchaka serhiy-storchaka Sep 13, 2021

Choose a reason for hiding this comment

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

Why not add deprecations when they are defined?

Copy link
Contributor Author

@erlend-aasland erlend-aasland Sep 13, 2021

Choose a reason for hiding this comment

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

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
Member

@serhiy-storchaka serhiy-storchaka Sep 13, 2021

Choose a reason for hiding this comment

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

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

Copy link
Contributor Author

@erlend-aasland erlend-aasland Sep 14, 2021

Choose a reason for hiding this comment

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

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 ambv merged commit ff6d2cc into python:main Sep 15, 2021
12 checks passed
@erlend-aasland erlend-aasland deleted the fix-issue-5846 branch Sep 15, 2021
@erlend-aasland
Copy link
Contributor Author

@erlend-aasland erlend-aasland commented Sep 15, 2021

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

lazka added a commit to lazka/distutils that referenced this issue Dec 27, 2021
See python/cpython#28299

loadTestsFromTestCase() is available since Python 2.7 at least.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
5 participants
X Tutup