[Python-Dev] Socket servers in the test suite

Vinay Sajip vinay_sajip at yahoo.co.uk
Wed Apr 27 23:23:48 CEST 2011


I've been recently trying to improve the test coverage for the logging package,
and have got to a not unreasonable point:

logging/__init__.py 99% (96%)
logging/config.py 89% (85%)
logging/handlers.py 60% (54%)

where the figures in parentheses include branch coverage measurements.

I'm at the point where to appreciably increase coverage, I'd need to write some
test servers to exercise client code in SocketHandler, DatagramHandler and
HTTPHandler.

I notice there are no utility classes in test.support to help with this kind of
thing - would there be any mileage in adding such things? Of course I could add
test server code just to test_logging (which already contains some socket server
code to exercise the configuration functionality), but rolling a test server
involves boilerplate such as using a custom RequestHandler-derived class for
each application. I had in mind a more streamlined approach where you can just
pass a single callable to a server to handle requests, e.g. as outlined in

https://gist.github.com/945157

I'd be grateful for any comments about adding such functionality to e.g.
test.support.

Regards,

Vinay Sajip



More information about the Python-Dev mailing list