summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_asyncore.py
Commit message (Collapse)AuthorAgeFilesLines
* - Issue #2550: The approach used by client/server code for obtaining portsTrent Nelson2008-04-081-421/+412
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | to listen on in network-oriented tests has been refined in an effort to facilitate running multiple instances of the entire regression test suite in parallel without issue. test_support.bind_port() has been fixed such that it will always return a unique port -- which wasn't always the case with the previous implementation, especially if socket options had been set that affected address reuse (i.e. SO_REUSEADDR, SO_REUSEPORT). The new implementation of bind_port() will actually raise an exception if it is passed an AF_INET/SOCK_STREAM socket with either the SO_REUSEADDR or SO_REUSEPORT socket option set. Furthermore, if available, bind_port() will set the SO_EXCLUSIVEADDRUSE option on the socket it's been passed. This currently only applies to Windows. This option prevents any other sockets from binding to the host/port we've bound to, thus removing the possibility of the 'non-deterministic' behaviour, as Microsoft puts it, that occurs when a second SOCK_STREAM socket binds and accepts to a host/port that's already been bound by another socket. The optional preferred port parameter to bind_port() has been removed. Under no circumstances should tests be hard coding ports! test_support.find_unused_port() has also been introduced, which will pass a temporary socket object to bind_port() in order to obtain an unused port. The temporary socket object is then closed and deleted, and the port is returned. This method should only be used for obtaining an unused port in order to pass to an external program (i.e. the -accept [port] argument to openssl's s_server mode) or as a parameter to a server-oriented class that doesn't give you direct access to the underlying socket used. Finally, test_support.HOST has been introduced, which should be used for the host argument of any relevant socket calls (i.e. bind and connect). The following tests were updated to following the new conventions: test_socket, test_smtplib, test_asyncore, test_ssl, test_httplib, test_poplib, test_ftplib, test_telnetlib, test_socketserver, test_asynchat and test_socket_ssl. It is now possible for multiple instances of the regression test suite to run in parallel without issue.
* Moved all of the capture_server socket setup code into the try blockFacundo Batista2007-07-281-9/+26
| | | | | | | | | so that the event gets set if a failure occurs during server setup (otherwise the test will block forever). Changed to let the OS assign the server port number, and client side of test waits for port number assignment before proceeding. The test data in DispatcherWithSendTests is also sent in multiple send() calls instead of one to make sure this works properly. [GSoC - Alan McIntyre]
* Selectively enable tests for asyncore.readwrite based on the presenceFacundo Batista2007-07-221-81/+77
| | | | | of poll support in the select module (since this is the only case in which readwrite can be called). [GSoC - Alan McIntyre]
* Added a select.select call in the test server loop to make sure theFacundo Batista2007-07-191-5/+7
| | | | | | socket is ready to be read from before attempting a read (this prevents an error 10035 on some Windows platforms). [GSoC - Alan McIntyre]
* Prevent asyncore.dispatcher tests from hanging by adding loop countersFacundo Batista2007-07-171-20/+46
| | | | | | to server & client, and by adding asyncore.close_all calls in tearDown. Also choose correct expected logging results based on the value of __debug__ [Alan McIntyre - GSoC]
* Changed the used port and commented out some tests that usesFacundo Batista2007-07-151-72/+82
| | | | | a non documented function that appers to uses resources not present in Windows.
* First version. Includes tests for helper functions: read, write,Facundo Batista2007-07-141-0/+370
_exception, readwrite, closeall, compact_traceback; and for classes dispatcher, dispatcher_with_send, and file_wrapper. [Alan McIntyre - GSoC]