Ignore:
Timestamp:
Apr 19, 2014, 11:16:52 PM (7 years ago)
Author:
Stefan Schwarzer <sschwarzer@…>
Branch:
default
Message:
Avoid `UnicodeDecodeError` for non-ASCII server messages.

See ticket #77.

The test simulates the server error by raising an `ftplib.error_perm`
directly.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • test/test_error.py

    r1481 r1483  
    4848            self.fail()
    4949
     50    def test_ftplib_error_to_ftp_os_error_non_ascii_server_message(self):
     51        """
     52        Test that we don't get a `UnicodeDecodeError` if the server
     53        sends a message containing non-ASCII characters.
     54        """
     55        # See ticket #77.
     56        message = \
     57          ftputil.tool.as_bytes("Não é possível criar um arquivo já existente.")
     58        try:
     59            with ftputil.error.ftplib_error_to_ftp_os_error:
     60                raise ftplib.error_perm(message)
     61        # We expect a `PermanentError`.
     62        except ftputil.error.PermanentError:
     63            pass
     64        except UnicodeDecodeError:
     65            self.fail()
     66
    5067    def test_ftplib_error_to_ftp_io_error(self):
    5168        """
Note: See TracChangeset for help on using the changeset viewer.