Changeset 127

Show
Ignore:
Timestamp:
2002-03-30 18:36:39 (7 years ago)
Author:
schwa
Message:
Module: renamed AsciiReadMockSession1 to ReadMockSession and
    AsciiReadMockSession2 to AsciiReadMockSession.
TestFileOperations: converted binary_readline to test_binary_readline.
Files:

Legend:

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

    r126 r127  
    3030# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
    3131 
    32 # $Id: _test_ftputil.py,v 1.39 2002/03/30 18:29:23 schwa Exp $ 
     32# $Id: _test_ftputil.py,v 1.40 2002/03/30 18:36:39 schwa Exp $ 
    3333 
    3434import unittest 
     
    4747        raise ftplib.error_perm 
    4848 
    49 class AsciiReadMockSession1(_mock_ftplib.MockSession): 
     49class ReadMockSession(_mock_ftplib.MockSession): 
    5050    mock_file_content = 'line 1\r\nanother line\r\nyet another line' 
    5151 
    52 class AsciiReadMockSession2(_mock_ftplib.MockSession): 
     52class AsciiReadMockSession(_mock_ftplib.MockSession): 
    5353    mock_file_content = '\r\n'.join( map( str, range(20) ) ) 
    5454 
     
    258258 
    259259    def test_ascii_writelines(self): 
    260         """Write data via writelines and check it.""" 
     260        """Write ASCII data via writelines and check it.""" 
    261261        host = ftp_host_factory() 
    262262        data = [' \n', 'line 2\n', 'line 3'] 
     
    272272 
    273273    def test_ascii_read(self): 
    274         """Write some ASCII data to the host and use plain 
    275         read operations to get it back. 
    276         """ 
    277         host = ftp_host_factory(session_factory=AsciiReadMockSession1) 
     274        """Use plain ASCII read operations to get data.""" 
     275        host = ftp_host_factory(session_factory=ReadMockSession) 
    278276        input_ = host.file('dummy', 'r') 
    279277        data = input_.read(0) 
     
    290288        # try it again with a more "problematic" string which 
    291289        #  makes several reads in the read() method necessary. 
    292         host = ftp_host_factory(session_factory=AsciiReadMockSession2
    293         expected_data = AsciiReadMockSession2.mock_file_content.\ 
     290        host = ftp_host_factory(session_factory=AsciiReadMockSession
     291        expected_data = AsciiReadMockSession.mock_file_content.\ 
    294292                        replace('\r\n', '\n') 
    295293        input_ = host.file('dummy', 'r') 
     
    298296 
    299297    def test_ascii_readline(self): 
    300         """Write some ASCII data to the (mock) host and use readline 
    301         operations to get it back. 
    302         """ 
    303         host = ftp_host_factory(session_factory=AsciiReadMockSession1) 
     298        """Use ASCII readline operations to get data.""" 
     299        host = ftp_host_factory(session_factory=ReadMockSession) 
    304300        input_ = host.file('dummy', 'r') 
    305301        data = input_.readline(3) 
     
    314310        self.assertEqual(data, '') 
    315311        input_.close() 
    316 
    317 #     def binary_readline(self): 
    318 #         """Write some ASCII data to the host and use binary 
    319 #         readline operations to get it back. 
    320 #         """ 
    321 #         host = self.host 
    322 #         # write some data 
    323 #         local_data = \ 
    324 #           'line 1\r\nanother line\r\nyet another line' 
    325 #         self.write_test_data(local_data, 'wb') 
    326 #         # read data with binary readline 
    327 #         input_ = host.file(self.remote_name, 'rb') 
    328 #         data = input_.readline(3) 
    329 #         self.assertEqual(data, 'lin') 
    330 #         data = input_.readline(10) 
    331 #         self.assertEqual(data, 'e 1\r\n') 
    332 #         data = input_.readline(13) 
    333 #         self.assertEqual(data, 'another line\r') 
    334 #         data = input_.readline() 
    335 #         self.assertEqual(data, '\n') 
    336 #         data = input_.readline() 
    337 #         self.assertEqual(data, 'yet another line') 
    338 #         data = input_.readline() 
    339 #         self.assertEqual(data, '') 
    340 #         input_.close() 
     312 
     313    def test_binary_readline(self): 
     314        """Use binary readline operations to get data.""" 
     315        host = ftp_host_factory(session_factory=ReadMockSession) 
     316        input_ = host.file('dummy', 'rb') 
     317        data = input_.readline(3) 
     318        self.assertEqual(data, 'lin') 
     319        data = input_.readline(10) 
     320        self.assertEqual(data, 'e 1\r\n') 
     321        data = input_.readline(13) 
     322        self.assertEqual(data, 'another line\r') 
     323        data = input_.readline() 
     324        self.assertEqual(data, '\n') 
     325        data = input_.readline() 
     326        self.assertEqual(data, 'yet another line') 
     327        data = input_.readline() 
     328        self.assertEqual(data, '') 
     329        input_.close() 
    341330# 
    342331#     def ascii_readlines(self): 
    343 #         """Write some ASCII data to the host and use readline 
    344 #         operations to get it back. 
    345 #         """ 
     332#         """Use readline operations to get data.""" 
    346333#         host = self.host 
    347334#         # write some data