mirror of
https://github.com/python/cpython.git
synced 2025-08-04 08:59:19 +00:00
bpo-45229: Remove test_main in many tests (GH-28405)
Instead of explicitly enumerate test classes for run_unittest() use the unittest ability to discover tests. This also makes these tests discoverable and runnable with unittest. load_tests() can be used for dynamic generating tests and adding doctests. setUpModule(), tearDownModule() and addModuleCleanup() can be used for running code before and after all module tests.
This commit is contained in:
parent
664448d81f
commit
40348acc18
61 changed files with 208 additions and 484 deletions
|
@ -5514,25 +5514,11 @@ class MiscTestCase(unittest.TestCase):
|
|||
# Set the locale to the platform-dependent default. I have no idea
|
||||
# why the test does this, but in any case we save the current locale
|
||||
# first and restore it at the end.
|
||||
@support.run_with_locale('LC_ALL', '')
|
||||
def test_main():
|
||||
tests = [
|
||||
BuiltinLevelsTest, BasicFilterTest, CustomLevelsAndFiltersTest,
|
||||
HandlerTest, MemoryHandlerTest, ConfigFileTest, SocketHandlerTest,
|
||||
DatagramHandlerTest, MemoryTest, EncodingTest, WarningsTest,
|
||||
ConfigDictTest, ManagerTest, FormatterTest, BufferingFormatterTest,
|
||||
StreamHandlerTest, LogRecordFactoryTest, ChildLoggerTest,
|
||||
QueueHandlerTest, ShutdownTest, ModuleLevelMiscTest, BasicConfigTest,
|
||||
LoggerAdapterTest, LoggerTest, SMTPHandlerTest, FileHandlerTest,
|
||||
RotatingFileHandlerTest, LastResortTest, LogRecordTest,
|
||||
ExceptionTest, SysLogHandlerTest, IPv6SysLogHandlerTest, HTTPHandlerTest,
|
||||
NTEventLogHandlerTest, TimedRotatingFileHandlerTest,
|
||||
UnixSocketHandlerTest, UnixDatagramHandlerTest, UnixSysLogHandlerTest,
|
||||
MiscTestCase
|
||||
]
|
||||
if hasattr(logging.handlers, 'QueueListener'):
|
||||
tests.append(QueueListenerTest)
|
||||
support.run_unittest(*tests)
|
||||
def setUpModule():
|
||||
cm = support.run_with_locale('LC_ALL', '')
|
||||
cm.__enter__()
|
||||
unittest.addModuleCleanup(cm.__exit__, None, None, None)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
test_main()
|
||||
unittest.main()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue