#140 closed defect (fixed)

Tests fail on darwin

Reported by: ftputiluser Owned by: schwa
Priority: minor Milestone:
Component: Test code Version: 4.0.0
Keywords: Cc:

Description (last modified by schwa)

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 #76.
        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

Change History (4)

comment:1 Changed 13 months ago by schwa

Description: modified (diff)

comment:2 Changed 13 months ago by schwa

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.

comment:3 Changed 13 months ago by schwa

It seems I found a way to write the test without relying on the exception message, see [b2b21ae7db1c].

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.

Last edited 13 months ago by schwa (previous) (diff)

comment:4 Changed 13 months ago by schwa

Resolution: fixed
Status: newclosed

A friend of mine confirmed that socket.EAI_NONAME indeed is the error code used in the gaierror on Darwin and Windows 10, so I'm confident the problem is fixed and close the ticket.

Note: See TracTickets for help on using tickets.