I am looking for a way of programmatically testing a script written with the asyncore Python module. My test consists of launching the script in question -- if a TCP listen socket is opened, the test passes. Otherwise, if the script dies before getting to that point, the test fails.
The purpose of this is knowing if a nightly build works (at least up to a point) or not. 
I was thinking the best way to test would be to launch the script in some kind of sandbox wrapper which waits for a socket request. I don't care about actually listening for anything on that port, just intercepting the request and using that as an indication that my test passed.
I think it would be preferable to intercept the open socket request, rather than polling at set intervals (I hate polling!). But I'm a bit out of my depths as far as how exactly to do this.
Can I do this with a shell script? Or perhaps I need to override the asyncore module at the Python level?
Thanks in advance,
- B
Another option is to mock the socket module before importing the asyncore module. Of course, then you have to make sure that the mock works properly first.
How can I build a wrapper to wait for listening on a port?