[New-bugs-announce] [issue43564] some tests in test_urllib2net fail instead of skipping on unreachable network

Carl Meyer report at bugs.python.org
Fri Mar 19 17:21:09 EDT 2021


New submission from Carl Meyer <carl at oddbird.net>:

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.

----------
components: Tests
messages: 389115
nosy: carljm
priority: normal
severity: normal
status: open
title: some tests in test_urllib2net fail instead of skipping on unreachable network
type: behavior
versions: Python 3.10

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue43564>
_______________________________________


More information about the New-bugs-announce mailing list