Changeset 140

Show
Ignore:
Timestamp:
2002-03-30 22:18:20 (7 years ago)
Author:
schwa
Message:
Module: reorganized and commented.
Files:

Legend:

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

    r139 r140  
    3030# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
    3131 
    32 # $Id: _test_ftputil.py,v 1.49 2002/03/30 22:14:53 schwa Exp $ 
     32# $Id: _test_ftputil.py,v 1.50 2002/03/30 22:18:20 schwa Exp $ 
    3333 
    3434import unittest 
     
    4444 
    4545 
    46 class FailOnLoginSession(_mock_ftplib.MockSession): 
    47     def __init__(self, host='', user='', password=''): 
    48         raise ftplib.error_perm 
    49  
    50 class ReadMockSession(_mock_ftplib.MockSession): 
    51     mock_file_content = 'line 1\r\nanother line\r\nyet another line' 
    52  
    53 class AsciiReadMockSession(_mock_ftplib.MockSession): 
    54     mock_file_content = '\r\n'.join( map( str, range(20) ) ) 
    55  
     46
     47# helper functions to generate random data 
     48
    5649def random_data(pool, size=10000): 
    5750    """ 
     
    7770    return random_data(pool) 
    7871 
     72# 
     73# several customized MockSession classes 
     74# 
     75class FailOnLoginSession(_mock_ftplib.MockSession): 
     76    def __init__(self, host='', user='', password=''): 
     77        raise ftplib.error_perm 
     78 
     79class ReadMockSession(_mock_ftplib.MockSession): 
     80    mock_file_content = 'line 1\r\nanother line\r\nyet another line' 
     81 
     82class AsciiReadMockSession(_mock_ftplib.MockSession): 
     83    mock_file_content = '\r\n'.join( map( str, range(20) ) ) 
     84 
    7985class BinaryDownloadMockSession(_mock_ftplib.MockSession): 
    8086    mock_file_content = binary_data() 
    8187 
    8288 
     89# 
     90# factory to produce FTPHost-like classes from a given FTPHost 
     91#  class and a given MockSession class 
    8392def ftp_host_factory(session_factory=_mock_ftplib.MockSession, 
    8493                     ftp_host_class=ftputil.FTPHost): 
     
    8796 
    8897 
     98# 
     99# test cases 
     100# 
    89101class TestLogin(unittest.TestCase): 
    90102    """Test invalid logins."""