You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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
unittest.TestLoader().loadTestsFromTestCase(...)
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.
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.
New changeset b2b035a by Serhiy Storchaka in branch 'main': bpo-5846: Fix deprecations for obsolete unittest functions and add tests. (GH-28382) b2b035a
Activity
voidspace commentedon Apr 25, 2009
_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?
birkenfeld commentedon Apr 27, 2009
I guess adding a standard DeprecationWarning is fine in these cases.
voidspace commentedon May 5, 2009
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
unittest.TestLoader().loadTestsFromTestCase(...)
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.
birkenfeld commentedon May 7, 2009
I'm sure Gerhard wouldn't say no to changing the sqlite3 test prefix to
"test_"...
voidspace commentedon May 11, 2009
Hehe - I wasn't actually doing that, just replacing the use of the
obsolete functions.
erlend-aasland commentedon Feb 9, 2021
FYI, the sqlite3 tests have now been cleaned up (GH-20538).
Remaining occurrences in Lib/test:
Lib/test/test_pdb.py: unittest.makeSuite(PdbTestCase),
Lib/test/test_dbm.py: suites = [unittest.makeSuite(c) for c in classes]
Lib/test/test_io.py: suite = unittest.TestSuite([unittest.makeSuite(test) for test in tests])
Lib/test/test_threading_local.py: suite.addTest(unittest.makeSuite(ThreadLocalTest))
Lib/test/test_threading_local.py: suite.addTest(unittest.makeSuite(PyThreadingLocalTest))
Lib/test/test_zipimport.py: # item in a list sorted by name, like unittest.makeSuite() does.)
Lib/test/support/init.py: suite.addTest(unittest.findTestCases(sys.modules[cls]))
Lib/test/support/init.py: suite.addTest(unittest.makeSuite(cls))
Lib/test/support/testresult.py: suite.addTest(unittest.makeSuite(TestTests))
Lib/test/test_email/torture_test.py: suite.addTest(unittest.makeSuite(testclass))
Lib/test/test_math.py: suite.addTest(unittest.makeSuite(MathTests))
Lib/test/test_math.py: suite.addTest(unittest.makeSuite(IsCloseTests))
serhiy-storchaka commentedon Sep 13, 2021
New changeset 851811f by Serhiy Storchaka in branch 'main':
bpo-5846: Do not use obsolete unittest functions. (GH-28303)
851811f
ambv commentedon Sep 15, 2021
New changeset ff6d2cc by Erlend Egeberg Aasland in branch 'main':
bpo-5846: Deprecate obsolete methods in
unittest(GH-28299)ff6d2cc
serhiy-storchaka commentedon Sep 15, 2021
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.
serhiy-storchaka commentedon Sep 17, 2021
New changeset b2b035a by Serhiy Storchaka in branch 'main':
bpo-5846: Fix deprecations for obsolete unittest functions and add tests. (GH-28382)
b2b035a
erlend-aasland commentedon Sep 17, 2021
_makeLoader is not deprecated yet, so we might keep this open a little bit more.
serhiy-storchaka commentedon Sep 17, 2021
It is an internal function. We can remove it without deprecation.
erlend-aasland commentedon Sep 18, 2021
How convenient :)
hugovk commentedon May 24, 2023
Please see PR #104836 to remove them in 3.13.