summaryrefslogtreecommitdiff
path: root/Lib/test/test_httpservers.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_httpservers.py
parent664448d81f41c5fa971d8523a71b0f19e76cc136 (diff)
downloadcpython-git-40348acc180580371d25f75f46b27048e35f2435.tar.gz
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_httpservers.py')
-rw-r--r--Lib/test/test_httpservers.py20
1 files changed, 4 insertions, 16 deletions
diff --git a/Lib/test/test_httpservers.py b/Lib/test/test_httpservers.py
index 69790ec746..1cc020f635 100644
--- a/Lib/test/test_httpservers.py
+++ b/Lib/test/test_httpservers.py
@@ -1302,21 +1302,9 @@ class ScriptTestCase(unittest.TestCase):
self.assertEqual(mock_server.address_family, socket.AF_INET)
-def test_main(verbose=None):
- cwd = os.getcwd()
- try:
- support.run_unittest(
- RequestHandlerLoggingTestCase,
- BaseHTTPRequestHandlerTestCase,
- BaseHTTPServerTestCase,
- SimpleHTTPServerTestCase,
- CGIHTTPServerTestCase,
- SimpleHTTPRequestHandlerTestCase,
- MiscTestCase,
- ScriptTestCase
- )
- finally:
- os.chdir(cwd)
+def setUpModule():
+ unittest.addModuleCleanup(os.chdir, os.getcwd())
+
if __name__ == '__main__':
- test_main()
+ unittest.main()