Changeset 118

Show
Ignore:
Timestamp:
2002-03-30 15:36:25 (7 years ago)
Author:
schwa
Message:
TestStat: added new method test_failing_lstat to test whether a
    non-existent directory/file raises an exception.
Module: refactored listdir tests into new class TestListdir.
Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/_test_ftputil.py

    r117 r118  
    3030# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
    3131 
    32 # $Id: _test_ftputil.py,v 1.32 2002/03/30 15:31:30 schwa Exp $ 
     32# $Id: _test_ftputil.py,v 1.33 2002/03/30 15:36:25 schwa Exp $ 
    3333 
    3434import unittest 
     
    5858 
    5959class TestStat(unittest.TestCase): 
    60     """Test FTPHost.lstat, FTPHost.stat, FTPHost.listdir. 
    61     (test currently only implemented for Unix server format. 
     60    """ 
     61    Test FTPHost.lstat and FTPHost.stat (test currently only 
     62    implemented for Unix server format). 
    6263    """ 
    6364 
     
    6566        """Test whether lstat fails for a nonexistent path.""" 
    6667        host = FTPHostWrapper(_mock_ftplib.MockSession) 
     68        self.assertRaises(ftputil.PermanentError, host.lstat, 
     69                          '/home/sschw/notthere') 
    6770        self.assertRaises(ftputil.PermanentError, host.lstat, 
    6871                          '/home/sschwarzer/notthere') 
     
    7477        self.assertEqual( oct(stat_result.st_mode), '0100644' ) 
    7578        self.assertEqual(stat_result.st_size, 4604) 
    76      
     79 
    7780    def test_lstat_one_dir(self): 
    7881        """Test FTPHost.lstat with a directory.""" 
     
    9194        self.assertEqual(stat_result.st_ctime, None) 
    9295        self.assertEqual(stat_result.st_name, 'scios2') 
    93      
     96 
    9497    def test_lstat_via_stat_module(self): 
    9598        """Test FTPHost.lstat indirectly via stat module.""" 
     
    98101        self.failUnless( stat.S_ISDIR(stat_result.st_mode) ) 
    99102 
    100     def test_listdir(self): 
    101         """Test FTPHost.listdir.""" 
    102         # try to list a path which isn't there 
     103 
     104class TestListdir(unittest.TestCase): 
     105    """Test FTPHost.listdir.""" 
     106 
     107    def test_failing_listdir(self): 
     108        """Test failing FTPHost.listdir.""" 
    103109        host = FTPHostWrapper(_mock_ftplib.MockSession) 
    104110        self.assertRaises(ftputil.PermanentError, 
    105111                          host.listdir, 'notthere') 
     112 
     113    def test_succeeding_listdir(self): 
     114        """Test succeeding FTPHost.listdir.""" 
    106115        # do we have all expected "files"? 
    107116        host = FTPHostWrapper(_mock_ftplib.MockSession) 
     
    200209#         input_.close() 
    201210#         self.assertEqual(local_data, remote_data) 
    202 #  
     211# 
    203212#     def ascii_write(self): 
    204213#         """Write an ASCII to the host and check the written file."""