summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_asynchat.py
Commit message (Collapse)AuthorAgeFilesLines
* Add import_function method to test.test_support, and modify a number ofR. David Murray2009-03-301-2/+4
| | | | | | | | tests that expect to be skipped if imports fail or functions don't exist to use import_function and import_module. The ultimate goal is to change regrtest to not skip automatically on ImportError. Checking in now to make sure the buldbots don't show any errors on platforms I can't direct test on.
* - Issue #2550: The approach used by client/server code for obtaining portsTrent Nelson2008-04-081-18/+15
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* Eliminate the sleeps that assume the server will start in .5 seconds.Neal Norwitz2008-01-271-20/+26
| | | | | This should make the test less flaky. It also speeds up the test by about 75% on my box (20+ seconds -> ~4 seconds).
* When running asynchat tests on OS X (darwin), the test client nowFacundo Batista2007-07-311-8/+14
| | | | | | | | overrides asyncore.dispatcher.handle_expt to do nothing, since select.poll gives a POLLHUP error at the completion of these tests. Added timeout & count arguments to several asyncore.loop calls to avoid the possibility of a test hanging up a build. [GSoC - Alan McIntyre]
* Added tests for asynchat classes simple_producer & fifo, and theFacundo Batista2007-07-291-26/+179
| | | | | | | | | find_prefix_at_end function. Check behavior of a string given as a producer. Added tests for behavior of asynchat.async_chat when given int, long, and None terminator arguments. Added usepoll attribute to TestAsynchat to allow running the asynchat tests with poll support chosen whether it's available or not (improves coverage of asyncore code). [GSoC - Alan McIntyre]
* Don't fail if another process is listening on our port.Neal Norwitz2006-06-131-1/+2
|
* test_asynchat is no longer expected to produce output.Michael W. Hudson2005-06-201-1/+3
| | | | also, wait for threads to finish before proceeding.
* Convert asynchat test to unittest; exercise the client using a numeric value ↵Andrew M. Kuchling2005-06-091-14/+46
| | | | as the terminator
* Replace backticks with repr() or "%r"Walter Dörwald2004-02-121-1/+1
| | | | From SF patch #852334.
* Set the SO_REUSEADDR socket option in the server thread -- this seemsGuido van Rossum2001-04-151-0/+1
| | | | | needed on some platforms (e.g. Solaris 8) when the test is run twice in quick succession.
* Add "import thread" at the top of the module; this prevents us fromGuido van Rossum2001-04-141-0/+1
| | | | | failing later when Python is compiled without threading but a failing 'threading' module can be imported due to an earlier (caught) attempt.
* After testing the test on Unix, several improvements:Guido van Rossum2001-04-061-3/+4
| | | | | | - Use push() instead of send(), and make these calls in main(). - Sleep a second to give the server thread time to initialize itself.
* Add test for asynchat. This also tests asyncore.Guido van Rossum2001-04-061-0/+55