[issue10116] Sporadic failures in test_urllibnet

Martin Panter report at bugs.python.org
Mon Jun 20 23:05:51 EDT 2016


Martin Panter added the comment:

It looks like Antoine’s second failure (test_getcode) should be fixed now that transient_internet() is used (Issue 12138).

Looking at Antoine’s first failure, it will always be possible for it to fail depending on the conditions of the buildbot, internet, and the www.example.com server:

def setUp(self):
    socket.setdefaulttimeout(self.TIMEOUT)

def testURLread(self):
    f = _open_with_retry(urllib.urlopen, "http://www.example.com/")
    x = f.read()  # Timed out!

I would suggest changing this to connect to a server running on localhost in a background thread, and moving it into test_urllib.py because it would no longer need the “network” resource. That should eliminate enough causes of a timeout, the remaining one being a very slow buildbot, which I don’t think is worth worrying about.

Also see revision aa46bdbe641d in Python 3, where the read() call was shifted under the transient_internet() handler, and seems to defeat the purpose of the test.

----------
nosy: +martin.panter
versions: +Python 2.7

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue10116>
_______________________________________


More information about the Python-bugs-list mailing list