Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 603dcf2

Browse files
committed
Spruce up test_xmlrpc by using ModuleNotFoundError and moving to
unittest.main().
1 parent d5b4e1d commit 603dcf2

1 file changed

Lines changed: 7 additions & 22 deletions

File tree

Lib/test/test_xmlrpc.py

Lines changed: 7 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,13 @@
1313
import contextlib
1414
from test import support
1515

16+
try:
17+
import gzip
18+
except ModuleNotFoundError:
19+
gzip = None
1620
try:
1721
import threading
18-
except ImportError:
22+
except ModuleNotFoundError:
1923
threading = None
2024

2125
alist = [{'astring': '[email protected]',
@@ -785,6 +789,7 @@ def test_transport(self):
785789

786790
#A test case that verifies that gzip encoding works in both directions
787791
#(for a request and the response)
792+
@unittest.skipIf(gzip is None, 'requires gzip')
788793
class GzipServerTestCase(BaseServerTestCase):
789794
#a request handler that supports keep-alive and logs requests into a
790795
#class variable
@@ -1074,25 +1079,5 @@ def test_xmlrpcserver_has_use_builtin_types_flag(self):
10741079
self.assertTrue(server.use_builtin_types)
10751080

10761081

1077-
@support.reap_threads
1078-
def test_main():
1079-
xmlrpc_tests = [XMLRPCTestCase, HelperTestCase, DateTimeTestCase,
1080-
BinaryTestCase, FaultTestCase]
1081-
xmlrpc_tests.append(UseBuiltinTypesTestCase)
1082-
xmlrpc_tests.append(SimpleServerTestCase)
1083-
xmlrpc_tests.append(KeepaliveServerTestCase1)
1084-
xmlrpc_tests.append(KeepaliveServerTestCase2)
1085-
try:
1086-
import gzip
1087-
xmlrpc_tests.append(GzipServerTestCase)
1088-
except ImportError:
1089-
pass #gzip not supported in this build
1090-
xmlrpc_tests.append(MultiPathServerTestCase)
1091-
xmlrpc_tests.append(ServerProxyTestCase)
1092-
xmlrpc_tests.append(FailingServerTestCase)
1093-
xmlrpc_tests.append(CGIHandlerTestCase)
1094-
1095-
support.run_unittest(*xmlrpc_tests)
1096-
10971082
if __name__ == "__main__":
1098-
test_main()
1083+
support.reap_threads(unittest.main)()

0 commit comments

Comments
 (0)