Changeset 134
- Timestamp:
- 2002-03-30 21:22:24 (7 years ago)
- Files:
-
- trunk/_test_ftputil.py (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/_test_ftputil.py
r132 r134 30 30 # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 31 32 # $Id: _test_ftputil.py,v 1.4 4 2002/03/30 18:56:56schwa Exp $32 # $Id: _test_ftputil.py,v 1.45 2002/03/30 21:22:24 schwa Exp $ 33 33 34 34 import unittest … … 37 37 import time 38 38 import operator 39 import random 39 40 40 41 import ftplib … … 240 241 output = host.file('dummy', 'wb') 241 242 output.write(data) 242 # must be checked _before_ close243 output.close() 243 244 child_data = host.file_content_for_child(0) 244 output.close()245 245 expected_data = data 246 246 self.assertEqual(child_data, expected_data) … … 252 252 output = host.file('dummy', 'w') 253 253 output.write(data) 254 output.close() 254 255 child_data = host.file_content_for_child(0) 255 output.close()256 256 expected_data = ' \r\nline 2\r\nline 3' 257 257 self.assertEqual(child_data, expected_data) … … 264 264 output = host.file('dummy', 'w') 265 265 output.writelines(data) 266 output.close() 266 267 child_data = host.file_content_for_child(0) 267 output.close()268 268 expected_data = ' \r\nline 2\r\nline 3' 269 269 self.assertEqual(child_data, expected_data) … … 371 371 'notthere', 'r') 372 372 373 # 374 # def test_upload_download(self): 375 # """Test FTPHost.upload/download.""" 376 # host = self.host 377 # local_source = 'ftputil.py' 378 # local_test_path = '__test.dat' 379 # remote_path = host.path.join(self.testdir, 380 # 'ftputil2.py') 373 def random_data(self, pool, size=10000): 374 """ 375 Return a sequence of characters consisting of those from 376 the pool of integer numbers. 377 """ 378 character_list = [] 379 for i in range(size): 380 ordinal = random.choice(pool) 381 character_list.append( chr(ordinal) ) 382 result = ''.join(character_list) 383 return result 384 385 def ascii_data(self): 386 """Return an ASCII character string.""" 387 pool = range(32, 128) 388 pool.append( ord('\n') ) 389 return self.random_data(pool) 390 391 def binary_data(self): 392 """Return an binary character string.""" 393 pool = range(0, 256) 394 return self.random_data(pool) 395 396 # def test_ascii_upload(self): 397 # """Test ASCII mode upload.""" 398 # # generate file 399 # source_file = open('__test_source', 'wb') 400 # source_file.write( self.ascii_data() ) 401 # source_file.close() 402 # # upload 403 # host = ftp_host_factory() 404 # local_source = '__test_source' 381 405 # # test ascii up/download 382 # host.upload(local_source, remote_path) 406 # host.upload(local_source, 'dummy') 407 # 383 408 # host.download(remote_path, local_test_path) 384 409 # # compare local data
