mirror of
https://github.com/python/cpython.git
synced 2025-07-24 11:44:31 +00:00

requires them. Disable executable bits and shebang lines in test and benchmark files in order to prevent using a random system python, and in source files of modules which don't provide command line interface. Fixed shebang line to use python3 executable in the unittestgui script.
57 lines
1.9 KiB
Python
57 lines
1.9 KiB
Python
import collections.abc
|
|
import errno
|
|
import socket
|
|
import sys
|
|
import unittest
|
|
from test import support
|
|
|
|
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 socket.error as e:
|
|
self.skipTest("network error: %s" % e)
|
|
|
|
# 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)
|
|
|
|
def test_python_builders(self):
|
|
# Get the list of builders from the XMLRPC buildbot interface at
|
|
# python.org.
|
|
server = xmlrpclib.ServerProxy("http://buildbot.python.org/all/xmlrpc/")
|
|
try:
|
|
builders = server.getAllBuilders()
|
|
except socket.error as e:
|
|
self.skipTest("network error: %s" % e)
|
|
self.addCleanup(lambda: server('close')())
|
|
|
|
# Perform a minimal sanity check on the result, just to be sure
|
|
# the request means what we think it means.
|
|
self.assertIsInstance(builders, collections.abc.Sequence)
|
|
self.assertTrue([x for x in builders if "3.x" in x], builders)
|
|
|
|
|
|
def test_main():
|
|
support.requires("network")
|
|
support.run_unittest(CurrentTimeTest)
|
|
|
|
if __name__ == "__main__":
|
|
test_main()
|