()
| 23 | |
| 24 | |
| 25 | def 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 | |
| 70 | class DocXMLRPCHTTPGETServer(unittest.TestCase): |
| 71 | def setUp(self): |
no test coverage detected
searching dependent graphs…