From: JINMEI Tatuya Date: Wed, 8 May 2013 03:43:17 +0000 (-0700) Subject: [master] use AF_UNIX socket.socket object instead of socket.socketpair()[0] X-Git-Tag: bind10-1.2.0beta1-release~474^2 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=7ece6fb69d2791ea263c080083a725c36e7a12ea;p=thirdparty%2Fkea.git [master] use AF_UNIX socket.socket object instead of socket.socketpair()[0] for "dummy" socket. in python3.1 the latter is of _socket.socket, which breaks the assumption of a test. okayed on bind10-dev. --- diff --git a/src/bin/stats/tests/test_utils.py b/src/bin/stats/tests/test_utils.py index 8b45f26d4b..8886ad2184 100644 --- a/src/bin/stats/tests/test_utils.py +++ b/src/bin/stats/tests/test_utils.py @@ -446,7 +446,7 @@ class MyStatsHttpd(stats_httpd.StatsHttpd): ORIG_SPECFILE_LOCATION = stats_httpd.SPECFILE_LOCATION def __init__(self, *server_address): self._started = threading.Event() - self.__dummy_socks = None # see below + self.__dummy_sock = None # see below # Prepare commonly used statistics schema and data requested in # stats-httpd tests. For the purpose of these tests, the content of @@ -501,10 +501,11 @@ class MyStatsHttpd(stats_httpd.StatsHttpd): # replace some (faked) ModuleCCSession methods so we can inspect/fake. # in order to satisfy select.select() we need some real socket. We - # use a socketpair(), but won't actually use it for communication. + # use an unusable AF_UNIX socket; we won't actually use it for + # communication. self.cc_session.rpc_call = self.__rpc_call - self.__dummy_socks = socket.socketpair() - self.mccs.get_socket = lambda: self.__dummy_socks[0] + self.__dummy_sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) + self.mccs.get_socket = lambda: self.__dummy_sock def open_mccs(self): self.mccs = MyModuleCCSession(stats_httpd.SPECFILE_LOCATION, @@ -515,10 +516,9 @@ class MyStatsHttpd(stats_httpd.StatsHttpd): def close_mccs(self): super().close_mccs() - if self.__dummy_socks is not None: - self.__dummy_socks[0].close() - self.__dummy_socks[1].close() - self.__dummy_socks = None + if self.__dummy_sock is not None: + self.__dummy_sock.close() + self.__dummy_sock = None def __rpc_call(self, command, group, params={}): """Faked ModuleCCSession.rpc_call for tests.