Probably nodename nor servname provided, or not known
needs to be
added to list of allowed outputs of the test_error_message_reuse
test.
log:
self = <test.test_error.TestErrorConversion object at 0x110663910>
def test_error_message_reuse(self):
"""
Test if the error message string is retained if the caught exception
has more than one element in `args`.
"""
# See ticket <a href="/~sschwarzer/ftputil/76" title="~sschwarzer/ftputil#76: Error message related to OS">#76</a>.
with pytest.raises(ftputil.error.FTPOSError) as exc_info:
# Format "host:port" doesn't work. The use here is intentional.
host = ftputil.FTPHost("localhost:21", "", "")
exc = exc_info.value
# The error message may be different for different Python versions.
> assert "No address associated with hostname" in str(
exc
) or "Name or service not known" in str(exc)
E AssertionError: assert ('No address associated with hostname' in '[Errno 8] nodename nor servname provided, or not known\nDebugging info: ftputil 4.0.0, Python 3.8.6 (darwin)' or 'Name or service not known' in '[Errno 8] nodename nor servname provided, or not known\nDebugging info: ftputil 4.0.0, Python 3.8.6 (darwin)')
E + where '[Errno 8] nodename nor servname provided, or not known\nDebugging info: ftputil 4.0.0, Python 3.8.6 (darwin)' = str(FTPOSError(8, 'nodename nor servname provided, or not known'))
E + and '[Errno 8] nodename nor servname provided, or not known\nDebugging info: ftputil 4.0.0, Python 3.8.6 (darwin)' = str(FTPOSError(8, 'nodename nor servname provided, or not known'))
test/test_error.py:66: AssertionError
Thanks for reporting the issue!
Yes, tests relying on error messages tend to be brittle.
For the record, the message doesn't seem to be specific for Python 3.8, because I ran the test on Python 3.8 before the release of ftputil 4.0.0. Most likely the message comes from the OS's C runtime.
I'll probably look into this issue on the weekend. Maybe I even find a way to do this test without error message checking, but let's see.
It seems I found a way to write the test without relying on the exception message, see 2d1dbdbefbc81b759e354ad5ee36617a9afee5f8.
Would you please update your repository and check if the tests work for you now? If you worked with the unpacked tar.gz release file, you can alternatively download the new versions of ftputil/error.py and test/test_error.py.
A friend of mine confirmed that
socket.EAI_NONAME
indeed is the error code used in thegaierror
on Darwin and Windows 10, so I'm confident the problem is fixed and close the ticket.