Changeset 1307:7f318aa1500d


Ignore:
Timestamp:
Aug 3, 2013, 1:26:29 PM (7 years ago)
Author:
Stefan Schwarzer <sschwarzer@…>
Branch:
default
Message:
Added tests for unicode/bytes paths in `rmtree` and `rename`.
Location:
test
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • test/mock_ftplib.py

    r1306 r1307  
    139139        self.current_dir = self._transform_path(path)
    140140
    141     def _ignore_path(self, path):
     141    def _ignore_arguments(self, *args, **kwargs):
    142142        pass
    143143
    144     delete = mkd = rmd = _ignore_path
     144    delete = mkd = rename = rmd = _ignore_arguments
    145145
    146146    def dir(self, *args):
  • test/test_host.py

    r1305 r1307  
    66
    77import ftplib
     8import itertools
    89import os
    910import posixpath
     
    489490        """Test whether `mkdir` accepts either unicode or bytes."""
    490491        host = self.host
    491         host.mkdir("/home/file_name_test/ö")
     492        # This directory exists already, but this shouldn't matter
     493        # for the test.
     494        host.mkdir("/home/file_name_test/ä")
    492495        host.mkdir(ftputil.tool.as_bytes("/home/file_name_test/ä"))
    493496
     
    495498        """Test whether `makedirs` accepts either unicode or bytes."""
    496499        host = self.host
    497         host.makedirs("/home/file_name_test/ö")
     500        host.makedirs("/home/file_name_test/ä")
    498501        host.makedirs(ftputil.tool.as_bytes("/home/file_name_test/ä"))
    499502
     
    513516    def test_rmtree(self):
    514517        """Test whether `rmtree` accepts either unicode or bytes."""
    515         pass
     518        host = self.host
     519        empty_directory_as_required_by_rmtree = "/home/file_name_test/empty_ä"
     520        host.rmtree(empty_directory_as_required_by_rmtree)
     521        host.rmtree(ftputil.tool.as_bytes(
     522                      empty_directory_as_required_by_rmtree))
    516523
    517524    def test_rename(self):
    518525        """Test whether `rename` accepts either unicode or bytes."""
    519526        # It's possible to mix argument types, as for `os.rename`.
    520         pass
     527        path_as_unicode = "/home/file_name_test/ä"
     528        path_as_bytes = ftputil.tool.as_bytes(path_as_unicode)
     529        paths = [path_as_unicode, path_as_bytes]
     530        for source_path, target_path in itertools.product(paths, paths):
     531            self.host.rename(source_path, target_path)
    521532
    522533    def test_listdir(self):
Note: See TracChangeset for help on using the changeset viewer.