You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
ftp tests in test_urllib2net should skip on unreachable network #87730
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
assignee=Noneclosed_at=Nonecreated_at=<Date2021-03-19.21:21:09.420>labels= ['type-bug', 'tests', '3.10']
title='ftp tests in test_urllib2net should skip on unreachable network'updated_at=<Date2021-06-23.19:18:02.469>user='https://github.com/carljm'
In general it seems the CPython test suite takes care to skip instead of failing networked tests when the network is unavailable (c.f. support.transient_internet test helper).
In this case of the 5 FTP tests in test_urllib2net (that is, test_ftp, test_ftp_basic, test_ftp_default_timeout, test_ftp_no_timeout, and test_ftp_timeout), even though they use support_transient_internet, they still fail if the network is unavailable.
The reason is that they make calls which end up raising an exception in the form URLError("ftp error: OSError(101, 'Network is unreachable')" -- the original OSError is flattened into the exception string message, but is otherwise not in the exception args. This means that transient_network does not detect it as a suppressable exception.
It seems like many uses of URLError in urllib pass the original OSError directly to URLError.__init__(), which means it ends up in args and the unwrapping code in transient_internet is able to find the original OSError. But the ftp code instead directly interpolates the OSError into a new message string.
changed the title [-]some tests in test_urllib2net fail instead of skipping on unreachable network[/-][+]ftp tests in test_urllib2net fail instead of skipping on unreachable network[/+]on Mar 19, 2021
changed the title [-]some tests in test_urllib2net fail instead of skipping on unreachable network[/-][+]ftp tests in test_urllib2net fail instead of skipping on unreachable network[/+]on Mar 19, 2021
Created a PR that fixes this by being more consistent in how urllib wraps network errors. If there are backward-compatibility concerns with this change, another option could be some really ugly regex-matching code in test.support.transient_internet.
changed the title [-]ftp tests in test_urllib2net fail instead of skipping on unreachable network[/-][+]ftp tests in test_urllib2net should skip on unreachable network[/+]on Mar 26, 2021
changed the title [-]ftp tests in test_urllib2net fail instead of skipping on unreachable network[/-][+]ftp tests in test_urllib2net should skip on unreachable network[/+]on Mar 26, 2021
Activity
carljm commentedon Mar 19, 2021
In general it seems the CPython test suite takes care to skip instead of failing networked tests when the network is unavailable (c.f.
support.transient_internettest helper).In this case of the 5 FTP tests in
test_urllib2net(that is,test_ftp,test_ftp_basic,test_ftp_default_timeout,test_ftp_no_timeout, andtest_ftp_timeout), even though they usesupport_transient_internet, they still fail if the network is unavailable.The reason is that they make calls which end up raising an exception in the form
URLError("ftp error: OSError(101, 'Network is unreachable')"-- the original OSError is flattened into the exception string message, but is otherwise not in the exception args. This means thattransient_networkdoes not detect it as a suppressable exception.It seems like many uses of
URLErrorin urllib pass the originalOSErrordirectly toURLError.__init__(), which means it ends up inargsand the unwrapping code intransient_internetis able to find the originalOSError. But the ftp code instead directly interpolates theOSErrorinto a new message string.[-]some tests in test_urllib2net fail instead of skipping on unreachable network[/-][+]ftp tests in test_urllib2net fail instead of skipping on unreachable network[/+][-]some tests in test_urllib2net fail instead of skipping on unreachable network[/-][+]ftp tests in test_urllib2net fail instead of skipping on unreachable network[/+]carljm commentedon Mar 19, 2021
Created a PR that fixes this by being more consistent in how urllib wraps network errors. If there are backward-compatibility concerns with this change, another option could be some really ugly regex-matching code in
test.support.transient_internet.[-]ftp tests in test_urllib2net fail instead of skipping on unreachable network[/-][+]ftp tests in test_urllib2net should skip on unreachable network[/+][-]ftp tests in test_urllib2net fail instead of skipping on unreachable network[/-][+]ftp tests in test_urllib2net should skip on unreachable network[/+]