Issue 2721: unittest.makeSuite undocumented and "obsolete" - but what to use instead? (original) (raw)

Issue2721

Created on 2008-04-29 22:26 by slinkp, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Messages (3)
msg65986 - (view) Author: Paul Winkler (slinkp) * Date: 2008-04-29 22:26
A comment in unittest.py says "these functions should be considered obsolete". But I've seen a lot of code in the wild still using unittest.makeSuite(MyTestCase)... in fact it's used frequently in the python standard library tests. And I don't see a replacement for this use case: given a subclass of TestCase, conveniently turn all its test* methods into a suite. How are we supposed to do that now? Either makeSuite should be documented, or a suitable replacement should be provided and documented.
msg66622 - (view) Author: Georg Brandl (georg.brandl) * (Python committer) Date: 2008-05-11 11:02
The replacement is TestLoader().loadTestsFromTestCase(), and it's already in a prominent place in the docs: """ Instead of :func:`unittest.main`, there are other ways to run the tests with a finer level of control, less terse output, and no requirement to be run from the command line. For example, the last two lines may be replaced with:: suite = unittest.TestLoader().loadTestsFromTestCase(TestSequenceFunctions) unittest.TextTestRunner(verbosity=2).run(suite) """ Closing as "works for me".
msg177820 - (view) Author: anatoly techtonik (techtonik) Date: 2012-12-20 13:58
What about? suite = unittest.makeSuite(SConfTestCase, 'test_')
History
Date User Action Args
2022-04-11 14:56:33 admin set github: 46973
2012-12-20 13:58:41 techtonik set nosy: + techtonikmessages: +
2008-05-11 11:02:15 georg.brandl set status: open -> closedresolution: works for memessages: +
2008-04-30 13:12:32 giampaolo.rodola set nosy: + giampaolo.rodola
2008-04-29 22:41:39 benjamin.peterson set nosy: + purcell
2008-04-29 22:26:30 slinkp create