[Python-Dev] Socket servers in the test suite (original) (raw)
Nick Coghlan ncoghlan at gmail.com
Thu Apr 28 04:24:48 CEST 2011
- Previous message: [Python-Dev] Socket servers in the test suite
- Next message: [Python-Dev] Socket servers in the test suite
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On Thu, Apr 28, 2011 at 7:23 AM, Vinay Sajip <vinay_sajip at yahoo.co.uk> wrote:
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 testlogging (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.
If you poke around in the test directory a bit, you may find there is already some code along these lines in other tests (e.g. I'm pretty sure the urllib tests already fire up a local server). Starting down the path of standardisation of that test functionality would be good.
For larger components like this, it's also reasonable to add a dedicated helper module rather than using test.support directly. I started (and Antoine improved) something along those lines with the test.script_helper module for running Python subprocesses and checking their output, although it lacks documentation and there are lots of older tests that still use subprocess directly.
Cheers, Nick.
-- Nick Coghlan | ncoghlan at gmail.com | Brisbane, Australia
- Previous message: [Python-Dev] Socket servers in the test suite
- Next message: [Python-Dev] Socket servers in the test suite
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]