MCPcopy Index your code
hub / github.com/python/cpython / make_server

Function make_server

Lib/test/test_docxmlrpc.py:25–68  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

23
24
25def make_server():
26 serv = DocXMLRPCServer(("localhost", 0), logRequests=False)
27
28 try:
29 # Add some documentation
30 serv.set_server_title("DocXMLRPCServer Test Documentation")
31 serv.set_server_name("DocXMLRPCServer Test Docs")
32 serv.set_server_documentation(
33 "This is an XML-RPC server's documentation, but the server "
34 "can be used by POSTing to /RPC2. Try self.add, too.")
35
36 # Create and register classes and functions
37 class TestClass(object):
38 def test_method(self, arg):
39 """Test method's docs. This method truly does very little."""
40 self.arg = arg
41
42 serv.register_introspection_functions()
43 serv.register_instance(TestClass())
44
45 def add(x, y):
46 """Add two instances together. This follows PEP008, but has nothing
47 to do with RFC1952. Case should matter: pEp008 and rFC1952. Things
48 that start with http and ftp should be auto-linked, too:
49 http://google.com.
50 """
51 return x + y
52
53 def annotation(x: int):
54 """ Use function annotations. """
55 return x
56
57 class ClassWithAnnotation:
58 def method_annotation(self, x: bytes):
59 return x.decode()
60
61 serv.register_function(add)
62 serv.register_function(lambda x, y: x-y)
63 serv.register_function(annotation)
64 serv.register_instance(ClassWithAnnotation())
65 return serv
66 except:
67 serv.server_close()
68 raise
69
70class DocXMLRPCHTTPGETServer(unittest.TestCase):
71 def setUp(self):

Callers 1

setUpMethod · 0.70

Calls 10

DocXMLRPCServerClass · 0.90
ClassWithAnnotationClass · 0.85
set_server_titleMethod · 0.80
set_server_nameMethod · 0.80
register_instanceMethod · 0.80
register_functionMethod · 0.80
TestClassClass · 0.70
server_closeMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…