Source

CherryPy / cherrypy / test / test_xmlrpc.py

The branch 'cherrypy-3.1.x' does not exist.
Diff from to

File cherrypy/test/test_xmlrpc.py

             return num * 2
         test_argument_passing.exposed = True
 
+        def test_returning_Fault(self):
+            return xmlrpclib.Fault(1, "custom Fault response")
+        test_returning_Fault.exposed = True
+
     root = Root()
     root.xmlrpc = XmlRpc()
     cherrypy.tree.mount(root, config={'/': {
         'request.dispatch': cherrypy.dispatch.XMLRPCDispatcher(),
+        'tools.xmlrpc.allow_none': 0,
         }})
     cherrypy.config.update({'environment': 'test_suite'})
 
         except AttributeError:
             pass
         
-        host = self.HOST
-        if host == '0.0.0.0':
-            # INADDR_ANY, which should respond on localhost.
-            host = "127.0.0.1"
-        if host == '::':
-            # IN6ADDR_ANY, which should respond on localhost.
-            host = "::1"
-        
         if scheme == "https":
-            url = 'https://%s:%s/xmlrpc/' % (host, self.PORT)
+            url = 'https://%s:%s/xmlrpc/' % (self.interface(), self.PORT)
             proxy = xmlrpclib.ServerProxy(url, transport=HTTPSTransport())
         else:
-            url = 'http://%s:%s/xmlrpc/' % (host, self.PORT)
+            url = 'http://%s:%s/xmlrpc/' % (self.interface(), self.PORT)
             proxy = xmlrpclib.ServerProxy(url)
         
         # begin the tests ...
                                              "for *: 'dict' and 'int'"))
         else:
             self.fail("Expected xmlrpclib.Fault")
-
+        
         # http://www.cherrypy.org/ticket/533
         # if a method is not found, an xmlrpclib.Fault should be raised
         try:
             self.assertEqual(x.faultString, 'method "non_method" is not supported')
         else:
             self.fail("Expected xmlrpclib.Fault")
+        
+        # Test returning a Fault from the page handler.
+        try:
+            proxy.test_returning_Fault()
+        except Exception, x:
+            self.assertEqual(x.__class__, xmlrpclib.Fault)
+            self.assertEqual(x.faultString, ("custom Fault response"))
+        else:
+            self.fail("Expected xmlrpclib.Fault")
 
 
 if __name__ == '__main__':