bitly/asyncmongo — pull request #32 by ajdavis (2011-12-14 19:54:04+00:00)
Title: Harden the unittests a little: close connections between tests, and stop the IOLoop before asserting.

I'd hit a bug where ConnectionPools kept sockets open while Mongo was restarted between tests, leading the next socket operation to to fail with "Connection reset by peer."

This patch also stops the IOLoop in test callbacks *before* making any assertions, to avoid the situation where a callback throws an AssertionError and aborts but leaves the loop running, meaning the test suite will hang forever. (Simply wrapping the outermost test function in a try ... except is insufficient, since Tornado's IOLoop swallows exceptions.)