Changeset 1612:f1bdb11422ab


Ignore:
Timestamp:
Nov 22, 2015, 7:31:03 PM (5 years ago)
Author:
Stefan Schwarzer <sschwarzer@…>
Branch:
default
Message:
Add test for path with non-latin1 unicode string

ftplib (under Python 2 and 3) raises a `UnicodeEncodeError` if
confronted with a path with non-latin1 characters. Test that ftputil
also raises the same exception. There's no sensible way to make
non-latin1 paths work as long as we build on ftplib.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • test/test_real_ftp.py

    r1609 r1612  
    838838        self.assertEqual(names[1], "file1_ö".encode("UTF-8").decode("latin1"))
    839839
     840    def test_path_with_non_latin1_unicode_string(self):
     841        """
     842        ftputil operations shouldn't accept file paths with non-latin1
     843        characters.
     844        """
     845        # Use some musical symbols. These are certainly not latin1.
     846        path = "𝄞𝄢"
     847        # `UnicodeEncodeError` is also the exception that `ftplib`
     848        # raises if it gets a non-latin1 path.
     849        with self.assertRaises(UnicodeEncodeError):
     850            self.host.mkdir(path)
     851
    840852    def test_list_a_option(self):
    841853        # For this test to pass, the server must _not_ list "hidden"
Note: See TracChangeset for help on using the changeset viewer.