This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Title: Deprecate obsolete functions in unittest
Type: enhancement Stage: resolved
Components: Library (Lib) Versions: Python 3.11
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: michael.foord Nosy List: erlendaasland, ezio.melotti, georg.brandl, lukasz.langa, michael.foord, serhiy.storchaka
Priority: normal Keywords: patch

Created on 2009-04-25 23:44 by michael.foord, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 20400 closed erlendaasland, 2020-05-25 21:56
PR 28299 merged erlendaasland, 2021-09-12 21:14
PR 28303 merged serhiy.storchaka, 2021-09-13 06:16
PR 28382 merged serhiy.storchaka, 2021-09-16 08:27
Messages (13)
msg86574 - (view) Author: Michael Foord (michael.foord) * (Python committer) Date: 2009-04-25 23:44
_makeLoader, getTestCaseNames, makeSuite and findTestCases have all had
the comment "these functions should be considered obsolete" for a long time.

Is is ok to go straight to deprecation or should they be marked with
PendingDeprecationWarning first?
msg86687 - (view) Author: Georg Brandl (georg.brandl) * (Python committer) Date: 2009-04-27 17:08
I guess adding a standard DeprecationWarning is fine in these cases.
msg87298 - (view) Author: Michael Foord (michael.foord) * (Python committer) Date: 2009-05-05 23:00
So it turns out that unittest.makeSuite is used about 100 times
throughout the standard library tests.

More than half the time it can be replaced with

Some of the other times a loader needs to be constructed and then a
testMethodPrefix of 'Check' set (yuck!).

I'm about halfway through a patch that does this. Think it is worth
continuing or shall I drop it. I don't mind doing it so long as
*someone* thinks it is worthwhile... :-)

(I haven't yet checked for getTestCaseNames but I imagine there will be
a bunch of these to fix as well.)

Another possibility is to move the functions into test_support
(deprecating first) where at least they are out of unittest.
msg87361 - (view) Author: Georg Brandl (georg.brandl) * (Python committer) Date: 2009-05-07 08:24
I'm sure Gerhard wouldn't say no to changing the sqlite3 test prefix to
msg87592 - (view) Author: Michael Foord (michael.foord) * (Python committer) Date: 2009-05-11 21:48
Hehe - I wasn't actually doing that, just replacing the use of the
obsolete functions.
msg386705 - (view) Author: Erlend E. Aasland (erlendaasland) * (Python triager) Date: 2021-02-09 10:45
> I'm sure Gerhard wouldn't say no to changing the sqlite3 test prefix to

FYI, the sqlite3 tests have now been cleaned up (GH-20538).

Remaining occurrences in Lib/test:
Lib/test/        unittest.makeSuite(PdbTestCase),
Lib/test/    suites = [unittest.makeSuite(c) for c in classes]
Lib/test/    suite = unittest.TestSuite([unittest.makeSuite(test) for test in tests])
Lib/test/    suite.addTest(unittest.makeSuite(ThreadLocalTest))
Lib/test/    suite.addTest(unittest.makeSuite(PyThreadingLocalTest))
Lib/test/        # item in a list sorted by name, like unittest.makeSuite() does.)
Lib/test/support/                suite.addTest(unittest.findTestCases(sys.modules[cls]))
Lib/test/support/            suite.addTest(unittest.makeSuite(cls))
Lib/test/support/    suite.addTest(unittest.makeSuite(TestTests))
Lib/test/test_email/        suite.addTest(unittest.makeSuite(testclass))
Lib/test/    suite.addTest(unittest.makeSuite(MathTests))
Lib/test/    suite.addTest(unittest.makeSuite(IsCloseTests))
msg401691 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2021-09-13 07:49
New changeset 851811f5772c43f72f445e2ce1ac3ea9da951ae3 by Serhiy Storchaka in branch 'main':
bpo-5846: Do not use obsolete unittest functions. (GH-28303)
msg401878 - (view) Author: Łukasz Langa (lukasz.langa) * (Python committer) Date: 2021-09-15 18:34
New changeset ff6d2cc55aac5cc53e331cae145d0cf35ec647b0 by Erlend Egeberg Aasland in branch 'main':
bpo-5846: Deprecate obsolete methods in `unittest` (GH-28299)
msg401899 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2021-09-15 19:50
I do not think that PR 28299 is correct. We want to deprecate these functions which are implemented in the unittest.loader module, not just names exported to the unittest module.
msg402014 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2021-09-17 09:09
New changeset b2b035a949eff1dc54b5bafe2bc9ce72b4d24438 by Serhiy Storchaka in branch 'main':
bpo-5846: Fix deprecations for obsolete unittest functions and add tests. (GH-28382)
msg402016 - (view) Author: Erlend E. Aasland (erlendaasland) * (Python triager) Date: 2021-09-17 09:13
_makeLoader is not deprecated yet, so we might keep this open a little bit more.
msg402042 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2021-09-17 11:54
It is an internal function. We can remove it without deprecation.
msg402126 - (view) Author: Erlend E. Aasland (erlendaasland) * (Python triager) Date: 2021-09-18 12:12
> It is an internal function. We can remove it without deprecation.

How convenient :)
Date User Action Args
2022-04-11 14:56:48adminsetgithub: 50096
2021-09-18 12:12:58erlendaaslandsetmessages: + msg402126
2021-09-17 11:54:09serhiy.storchakasetmessages: + msg402042
2021-09-17 09:13:12erlendaaslandsetmessages: + msg402016
2021-09-17 09:11:48serhiy.storchakasetstatus: open -> closed
resolution: fixed
stage: patch review -> resolved
2021-09-17 09:10:06serhiy.storchakasetversions: + Python 3.11, - Python 3.4
2021-09-17 09:09:36serhiy.storchakasetmessages: + msg402014
2021-09-16 08:27:20serhiy.storchakasetpull_requests: + pull_request26797
2021-09-15 19:50:36serhiy.storchakasetmessages: + msg401899
2021-09-15 18:34:09lukasz.langasetnosy: + lukasz.langa
messages: + msg401878
2021-09-13 07:49:57serhiy.storchakasetmessages: + msg401691
2021-09-13 06:16:57serhiy.storchakasetnosy: + serhiy.storchaka
pull_requests: + pull_request26717
2021-09-12 21:14:28erlendaaslandsetpull_requests: + pull_request26713
2021-02-09 10:45:14erlendaaslandsetmessages: + msg386705
2020-05-25 21:56:49erlendaaslandsetkeywords: + patch
nosy: + erlendaasland

pull_requests: + pull_request19663
stage: needs patch -> patch review
2012-09-26 17:29:06ezio.melottisettype: enhancement
versions: + Python 3.4, - Python 3.3
2011-03-16 02:24:46ezio.melottisetstage: needs patch
versions: + Python 3.3, - Python 3.1, Python 2.7
2011-01-03 22:48:26ezio.melottisetnosy: + ezio.melotti
2009-05-11 21:48:40michael.foordsetmessages: + msg87592
2009-05-07 08:24:24georg.brandlsetmessages: + msg87361
2009-05-05 23:00:08michael.foordsetmessages: + msg87298
2009-04-27 17:08:35georg.brandlsetnosy: + georg.brandl
messages: + msg86687
2009-04-25 23:44:59michael.foordcreate