-
-
Notifications
You must be signed in to change notification settings - Fork 2k
Description
A lot of the "random" test failures on Travis of late are mostly, I think, due to interactions with OS sockets over which we don't have full control, and which can lead to unpredictable behavior.
I wonder if it wouldn't be better to just mock the entire socket module for these purposes, using a lightweight Python replacement for sockets without touching real OS level sockets. For the most part I don't think we require any advanced socket features so this should be reasonably straightforward.
There is one project already called "mocket" which provides this: https://github.com/mocketize/python-mocket, though it doesn't seem to have had much active development in the last year. It still looks okay though. There's also a mock_socket.py hanging out in Python itself: http://hg.python.org/cpython/file/718cddfa0292/Lib/test/mock_socket.py
This is not a normally installed module, but it could just be copied verbatim with the proper attribution. Or, depending on what we determine our actual needs to be, it may be straightforward enough to roll our own.
This isn't something I'd want to put a lot of effort into if it winds up being troublesome. But I think it could really improve the reliability of our tests without implicitly also testing sockets, which really doesn't help us in general.