[Python-checkins] cpython: #19192: Give up on time.xmlrpc.com as an xmlrpc network test.

r.david.murray python-checkins at python.org
Fri Oct 11 18:10:10 CEST 2013


http://hg.python.org/cpython/rev/a4515186bf9c
changeset:   86210:a4515186bf9c
user:        R David Murray <rdmurray at bitdance.com>
date:        Fri Oct 11 12:09:51 2013 -0400
summary:
  #19192: Give up on time.xmlrpc.com as an xmlrpc network test.

time.xmlrpc.com has come and gone over the years, and has been gone again for
a while.  The test did test one thing that the current xmlrpc tests don't: the
use of multiple levels of attribute names in the call.  So in addition to
removing the network test, we add a test in xmlrpc of dotted name access.

There should also be a test for when dotted name access is disallowed, but
that requires more extensive test harness refactoring, and in any case was not
tested by the network test we are deleting, since it is a server-side setting.

This is a slightly simplified version of a patch by Vajrasky Kok.

files:
  Lib/test/test_xmlrpc.py     |  17 ++++++++++++-
  Lib/test/test_xmlrpc_net.py |  29 +-----------------------
  2 files changed, 17 insertions(+), 29 deletions(-)


diff --git a/Lib/test/test_xmlrpc.py b/Lib/test/test_xmlrpc.py
--- a/Lib/test/test_xmlrpc.py
+++ b/Lib/test/test_xmlrpc.py
@@ -380,6 +380,11 @@
             if name == 'div':
                 return 'This is the div function'
 
+        class Fixture:
+            @staticmethod
+            def getData():
+                return '42'
+
     def my_function():
         '''This is my function'''
         return True
@@ -411,7 +416,8 @@
         serv.register_function(pow)
         serv.register_function(lambda x,y: x+y, 'add')
         serv.register_function(my_function)
-        serv.register_instance(TestInstanceClass())
+        testInstance = TestInstanceClass()
+        serv.register_instance(testInstance, allow_dotted_names=True)
         evt.set()
 
         # handle up to 'numrequests' requests
@@ -591,7 +597,8 @@
     def test_introspection1(self):
         expected_methods = set(['pow', 'div', 'my_function', 'add',
                                 'system.listMethods', 'system.methodHelp',
-                                'system.methodSignature', 'system.multicall'])
+                                'system.methodSignature', 'system.multicall',
+                                'Fixture'])
         try:
             p = xmlrpclib.ServerProxy(URL)
             meth = p.system.listMethods()
@@ -690,6 +697,12 @@
         # This avoids waiting for the socket timeout.
         self.test_simple1()
 
+    def test_allow_dotted_names_true(self):
+        # XXX also need allow_dotted_names_false test.
+        server = xmlrpclib.ServerProxy("http://%s:%d/RPC2" % (ADDR, PORT))
+        data = server.Fixture.getData()
+        self.assertEqual(data, '42')
+
     def test_unicode_host(self):
         server = xmlrpclib.ServerProxy("http://%s:%d/RPC2" % (ADDR, PORT))
         self.assertEqual(server.add("a", "\xe9"), "a\xe9")
diff --git a/Lib/test/test_xmlrpc_net.py b/Lib/test/test_xmlrpc_net.py
--- a/Lib/test/test_xmlrpc_net.py
+++ b/Lib/test/test_xmlrpc_net.py
@@ -9,32 +9,7 @@
 
 import xmlrpc.client as xmlrpclib
 
-class CurrentTimeTest(unittest.TestCase):
-
-    def test_current_time(self):
-        # Get the current time from xmlrpc.com.  This code exercises
-        # the minimal HTTP functionality in xmlrpclib.
-        self.skipTest("time.xmlrpc.com is unreliable")
-        server = xmlrpclib.ServerProxy("http://time.xmlrpc.com/RPC2")
-        try:
-            t0 = server.currentTime.getCurrentTime()
-        except OSError as e:
-            self.skipTest("network error: %s" % e)
-            return
-
-        # Perform a minimal sanity check on the result, just to be sure
-        # the request means what we think it means.
-        t1 = xmlrpclib.DateTime()
-
-        dt0 = xmlrpclib._datetime_type(t0.value)
-        dt1 = xmlrpclib._datetime_type(t1.value)
-        if dt0 > dt1:
-            delta = dt0 - dt1
-        else:
-            delta = dt1 - dt0
-        # The difference between the system time here and the system
-        # time on the server should not be too big.
-        self.assertTrue(delta.days <= 1)
+class PythonBuildersTest(unittest.TestCase):
 
     def test_python_builders(self):
         # Get the list of builders from the XMLRPC buildbot interface at
@@ -55,7 +30,7 @@
 
 def test_main():
     support.requires("network")
-    support.run_unittest(CurrentTimeTest)
+    support.run_unittest(PythonBuildersTest)
 
 if __name__ == "__main__":
     test_main()

-- 
Repository URL: http://hg.python.org/cpython


More information about the Python-checkins mailing list