Changeset 773:de1877c8c9d6


Ignore:
Timestamp:
Apr 5, 2009, 8:09:43 PM (12 years ago)
Author:
Stefan Schwarzer <sschwarzer@…>
Branch:
default
Convert:
svn:778c30c8-61e0-0310-89d4-fe2f97a467b2/trunk@810
Message:
Give a more helpful error message if an item to remove doesn't
exist at all.
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • _test_real_ftp.py

    r734 r773  
    1 # Copyright (C) 2003-2008, Stefan Schwarzer
     1# Copyright (C) 2003-2009, Stefan Schwarzer
    22# All rights reserved.
    33#
     
    468468
    469469    #
     470    # remove/unlink
     471    #
     472    def test_remove_non_existent_item(self):
     473        host = self.host
     474        self.assertRaises(ftp_error.PermanentError, host.remove, "nonexistent")
     475   
     476    def test_remove_existent_file(self):
     477        self.cleaner.add_file('_testfile_')
     478        self.make_file('_testfile_')
     479        host = self.host
     480        self.failUnless(host.path.isfile('_testfile_'))
     481        host.remove('_testfile_')
     482        self.failIf(host.path.exists('_testfile_'))
     483
     484    #
    470485    # `chmod`
    471486    #
  • ftputil.py

    r736 r773  
    1 # Copyright (C) 2002-2008, Stefan Schwarzer <sschwarzer@sschwarzer.net>
     1# Copyright (C) 2002-2009, Stefan Schwarzer <sschwarzer@sschwarzer.net>
    22# All rights reserved.
    33#
     
    664664        # though `isfile` includes also links to files, `islink`
    665665        #  is needed to include links to directories
    666         if self.path.isfile(path) or self.path.islink(path):
     666        # if the path doesn't exist, let the removal command trigger
     667        #  an exception with a more appropriate error message
     668        if self.path.isfile(path) or self.path.islink(path) or \
     669           not self.path.exists(path):
    667670            def command(self, path):
    668671                """Callback function."""
Note: See TracChangeset for help on using the changeset viewer.