Changeset 127
- Timestamp:
- 2002-03-30 18:36:39 (7 years ago)
- Files:
-
- trunk/_test_ftputil.py (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/_test_ftputil.py
r126 r127 30 30 # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 31 32 # $Id: _test_ftputil.py,v 1. 39 2002/03/30 18:29:23schwa Exp $32 # $Id: _test_ftputil.py,v 1.40 2002/03/30 18:36:39 schwa Exp $ 33 33 34 34 import unittest … … 47 47 raise ftplib.error_perm 48 48 49 class AsciiReadMockSession1(_mock_ftplib.MockSession):49 class ReadMockSession(_mock_ftplib.MockSession): 50 50 mock_file_content = 'line 1\r\nanother line\r\nyet another line' 51 51 52 class AsciiReadMockSession 2(_mock_ftplib.MockSession):52 class AsciiReadMockSession(_mock_ftplib.MockSession): 53 53 mock_file_content = '\r\n'.join( map( str, range(20) ) ) 54 54 … … 258 258 259 259 def test_ascii_writelines(self): 260 """Write data via writelines and check it."""260 """Write ASCII data via writelines and check it.""" 261 261 host = ftp_host_factory() 262 262 data = [' \n', 'line 2\n', 'line 3'] … … 272 272 273 273 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) 278 276 input_ = host.file('dummy', 'r') 279 277 data = input_.read(0) … … 290 288 # try it again with a more "problematic" string which 291 289 # makes several reads in the read() method necessary. 292 host = ftp_host_factory(session_factory=AsciiReadMockSession 2)293 expected_data = AsciiReadMockSession 2.mock_file_content.\290 host = ftp_host_factory(session_factory=AsciiReadMockSession) 291 expected_data = AsciiReadMockSession.mock_file_content.\ 294 292 replace('\r\n', '\n') 295 293 input_ = host.file('dummy', 'r') … … 298 296 299 297 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) 304 300 input_ = host.file('dummy', 'r') 305 301 data = input_.readline(3) … … 314 310 self.assertEqual(data, '') 315 311 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() 341 330 # 342 331 # 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.""" 346 333 # host = self.host 347 334 # # write some data
