Skip to content

Commit c7976da

Browse files
bpo-35411: Skip test_urllib2net FTP tests on Travis CI (GH-10907)
On Travis CI, FTP tests of test_urllib2net randomly fail with "425 Security: Bad IP connecting". test.pythoninfo now also logs TRAVIS environment variable. (cherry picked from commit c11b3b1) Co-authored-by: Victor Stinner <vstinner@redhat.com>
1 parent 93d7918 commit c7976da

2 files changed

Lines changed: 13 additions & 0 deletions

File tree

‎Lib/test/pythoninfo.py‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,7 @@ def format_groups(groups):
256256
"TIX_LIBRARY",
257257
"TMP",
258258
"TMPDIR",
259+
"TRAVIS",
259260
"TZ",
260261
"USERPROFILE",
261262
"VIRTUAL_ENV",

‎Lib/test/test_urllib2net.py‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,13 @@ def wrapped(*args, **kwargs):
2525
return _retry_thrice(func, exc, *args, **kwargs)
2626
return wrapped
2727

28+
# bpo-35411: FTP tests of test_urllib2net randomly fail
29+
# with "425 Security: Bad IP connecting" on Travis CI
30+
skip_ftp_test_on_travis = unittest.skipIf('TRAVIS' in os.environ,
31+
'bpo-35411: skip FTP test '
32+
'on Travis CI')
33+
34+
2835
# Connecting to remote hosts is flaky. Make it more robust by retrying
2936
# the connection several times.
3037
_urlopen_with_retry = _wrap_with_retry_thrice(urllib2.urlopen, urllib2.URLError)
@@ -100,6 +107,7 @@ def setUp(self):
100107
# XXX The rest of these tests aren't very good -- they don't check much.
101108
# They do sometimes catch some major disasters, though.
102109

110+
@skip_ftp_test_on_travis
103111
def test_ftp(self):
104112
urls = [
105113
'ftp://www.pythontest.net/README',
@@ -285,12 +293,14 @@ def test_http_timeout(self):
285293

286294
FTP_HOST = 'ftp://www.pythontest.net/'
287295

296+
@skip_ftp_test_on_travis
288297
def test_ftp_basic(self):
289298
self.assertIsNone(socket.getdefaulttimeout())
290299
with test_support.transient_internet(self.FTP_HOST, timeout=None):
291300
u = _urlopen_with_retry(self.FTP_HOST)
292301
self.assertIsNone(u.fp.fp._sock.gettimeout())
293302

303+
@skip_ftp_test_on_travis
294304
def test_ftp_default_timeout(self):
295305
self.assertIsNone(socket.getdefaulttimeout())
296306
with test_support.transient_internet(self.FTP_HOST):
@@ -301,6 +311,7 @@ def test_ftp_default_timeout(self):
301311
socket.setdefaulttimeout(None)
302312
self.assertEqual(u.fp.fp._sock.gettimeout(), 60)
303313

314+
@skip_ftp_test_on_travis
304315
def test_ftp_no_timeout(self):
305316
self.assertIsNone(socket.getdefaulttimeout(),)
306317
with test_support.transient_internet(self.FTP_HOST):
@@ -311,6 +322,7 @@ def test_ftp_no_timeout(self):
311322
socket.setdefaulttimeout(None)
312323
self.assertIsNone(u.fp.fp._sock.gettimeout())
313324

325+
@skip_ftp_test_on_travis
314326
def test_ftp_timeout(self):
315327
with test_support.transient_internet(self.FTP_HOST):
316328
u = _urlopen_with_retry(self.FTP_HOST, timeout=60)

0 commit comments

Comments
 (0)