7 from test
import support
9 import xmlrpc
.client
as xmlrpclib
11 class CurrentTimeTest(unittest
.TestCase
):
13 def test_current_time(self
):
14 # Get the current time from xmlrpc.com. This code exercises
15 # the minimal HTTP functionality in xmlrpclib.
16 server
= xmlrpclib
.ServerProxy("http://time.xmlrpc.com/RPC2")
18 t0
= server
.currentTime
.getCurrentTime()
19 except socket
.error
as e
:
20 print(" test_current_time: skipping test, got error: %s" % e
,
24 # Perform a minimal sanity check on the result, just to be sure
25 # the request means what we think it means.
26 t1
= xmlrpclib
.DateTime()
28 dt0
= xmlrpclib
._datetime
_type
(t0
.value
)
29 dt1
= xmlrpclib
._datetime
_type
(t1
.value
)
34 # The difference between the system time here and the system
35 # time on the server should not be too big.
36 self
.assert_(delta
.days
<= 1)
40 support
.requires("network")
41 support
.run_unittest(CurrentTimeTest
)
43 if __name__
== "__main__":