diff options
author | Jeremy Hylton <jeremy@alum.mit.edu> | 2007-08-14 16:47:39 (GMT) |
---|---|---|
committer | Jeremy Hylton <jeremy@alum.mit.edu> | 2007-08-14 16:47:39 (GMT) |
commit | 5d8a88a442f1f24b8bc3ff85ffae44d8d151b91c (patch) | |
tree | 03579807f174ab6c8e93695f2b12d3975ab5c48e /Lib/test | |
parent | 956e359579abf3a5fd88783ee625c2e0ca30bf60 (diff) | |
download | cpython-5d8a88a442f1f24b8bc3ff85ffae44d8d151b91c.zip cpython-5d8a88a442f1f24b8bc3ff85ffae44d8d151b91c.tar.gz cpython-5d8a88a442f1f24b8bc3ff85ffae44d8d151b91c.tar.bz2 |
Change xmlrpclib to use the newer httplib interface.
Note that it's hard to test xmlrpclib, because the server it attempts
to connect to doesn't seem to support the expected interfaces. Many
of the links via xmlrpc.com are dead, so I couldn't find another
server to use for tests.
Diffstat (limited to 'Lib/test')
-rw-r--r-- | Lib/test/test_xmlrpc_net.py | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/Lib/test/test_xmlrpc_net.py b/Lib/test/test_xmlrpc_net.py new file mode 100644 index 0000000..4751d57 --- /dev/null +++ b/Lib/test/test_xmlrpc_net.py @@ -0,0 +1,36 @@ +#!/usr/bin/env python + +import unittest +from test import test_support + +import 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. + server = xmlrpclib.ServerProxy("http://time.xmlrpc.com/RPC2") + t0 = server.currentTime.getCurrentTime() + + # 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.assert_(delta.days <= 1) + + +def test_main(): + test_support.requires("network") + test_support.run_unittest(CurrentTimeTest) + +if __name__ == "__main__": + test_main() |