aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/Lib/test/test_logging.py
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2021-09-19 15:27:33 +0300
committerGitHub <noreply@github.com>2021-09-19 15:27:33 +0300
commit40348acc180580371d25f75f46b27048e35f2435 (patch)
tree4ddb641b0dfc1edda6d0a6c044c1380c4900d58a /Lib/test/test_logging.py
parent664448d81f41c5fa971d8523a71b0f19e76cc136 (diff)
downloadcpython-40348acc180580371d25f75f46b27048e35f2435.tar.gz
cpython-40348acc180580371d25f75f46b27048e35f2435.zip
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.
Diffstat (limited to 'Lib/test/test_logging.py')
-rw-r--r--Lib/test/test_logging.py26
1 files changed, 6 insertions, 20 deletions
diff --git a/Lib/test/test_logging.py b/Lib/test/test_logging.py
index 9998f1a02e4..211fe4bbd7b 100644
--- a/Lib/test/test_logging.py
+++ b/Lib/test/test_logging.py
@@ -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()