@@ -434,3 +434,85 @@ def test_scp_send_large_file(self):
434
434
os .unlink (_path )
435
435
except Exception :
436
436
pass
437
+
438
+ def test_scp_send_dir_target (self ):
439
+ cur_dir = os .path .dirname (__file__ )
440
+ file_name = 'file1'
441
+ file_path_from = os .path .sep .join ([cur_dir , file_name ])
442
+ file_copy_to_dirpath = os .path .expanduser ('~/' )
443
+ file_copy_to_abs = file_copy_to_dirpath + file_name
444
+ for _path in (file_path_from , file_copy_to_abs ):
445
+ try :
446
+ os .unlink (_path )
447
+ except OSError :
448
+ pass
449
+ try :
450
+ with open (file_path_from , 'wb' ) as fh :
451
+ fh .write (b"adsfasldkfjabafj" )
452
+ self .client .scp_send (file_path_from , file_copy_to_dirpath )
453
+ self .assertTrue (os .path .isfile (file_copy_to_abs ))
454
+ finally :
455
+ for _path in (file_path_from , file_copy_to_abs ):
456
+ try :
457
+ os .unlink (_path )
458
+ except OSError :
459
+ pass
460
+ # Relative path
461
+ file_copy_to_dirpath = './'
462
+ for _path in (file_path_from , file_copy_to_abs ):
463
+ try :
464
+ os .unlink (_path )
465
+ except OSError :
466
+ pass
467
+ try :
468
+ with open (file_path_from , 'wb' ) as fh :
469
+ fh .write (b"adsfasldkfjabafj" )
470
+ self .client .scp_send (file_path_from , file_copy_to_dirpath )
471
+ self .assertTrue (os .path .isfile (file_copy_to_abs ))
472
+ finally :
473
+ for _path in (file_path_from , file_copy_to_abs ):
474
+ try :
475
+ os .unlink (_path )
476
+ except OSError :
477
+ pass
478
+
479
+ def test_scp_recv_dir_target (self ):
480
+ cur_dir = os .path .dirname (__file__ )
481
+ file_name = 'file1'
482
+ file_path_from = os .path .sep .join ([cur_dir , file_name ])
483
+ file_copy_to_dirpath = os .path .expanduser ('~/' )
484
+ file_copy_to_abs = file_copy_to_dirpath + file_name
485
+ for _path in (file_path_from , file_copy_to_abs ):
486
+ try :
487
+ os .unlink (_path )
488
+ except OSError :
489
+ pass
490
+ try :
491
+ with open (file_path_from , 'wb' ) as fh :
492
+ fh .write (b"adsfasldkfjabafj" )
493
+ self .client .scp_recv (file_path_from , file_copy_to_dirpath )
494
+ self .assertTrue (os .path .isfile (file_copy_to_abs ))
495
+ finally :
496
+ for _path in (file_path_from , file_copy_to_abs ):
497
+ try :
498
+ os .unlink (_path )
499
+ except OSError :
500
+ pass
501
+ # Relative path
502
+ file_copy_to_dirpath = './'
503
+ for _path in (file_path_from , file_copy_to_abs ):
504
+ try :
505
+ os .unlink (_path )
506
+ except OSError :
507
+ pass
508
+ try :
509
+ with open (file_path_from , 'wb' ) as fh :
510
+ fh .write (b"adsfasldkfjabafj" )
511
+ self .client .scp_send (file_path_from , file_copy_to_dirpath )
512
+ self .assertTrue (os .path .isfile (file_copy_to_abs ))
513
+ finally :
514
+ for _path in (file_path_from , file_copy_to_abs ):
515
+ try :
516
+ os .unlink (_path )
517
+ except OSError :
518
+ pass
0 commit comments