@@ -521,21 +521,13 @@ def test_islink_with_trailing_sep_macos(self):
521521 self .os .symlink (self .base_path , link_path )
522522 self .assertFalse (self .os .path .islink (link_path + self .os .sep ))
523523
524- def check_getsize_raises_with_trailing_separator (self , error_nr ):
524+ def test_getsize_raises_with_trailing_separator (self ):
525525 file_path = self .make_path ("bar" )
526526 self .create_file (file_path )
527527 self .assert_raises_os_error (
528- error_nr , self .os .path .getsize , file_path + self .os .sep
528+ errno . ENOTDIR , self .os .path .getsize , file_path + self .os .sep
529529 )
530530
531- def test_getsize_raises_with_trailing_separator_posix (self ):
532- self .check_posix_only ()
533- self .check_getsize_raises_with_trailing_separator (errno .ENOTDIR )
534-
535- def test_getsize_raises_with_trailing_separator_windows (self ):
536- self .check_windows_only ()
537- self .check_getsize_raises_with_trailing_separator (errno .EINVAL )
538-
539531 def check_remove_link_ending_with_sep (self , error_nr ):
540532 # regression test for #360
541533 link_path = self .make_path ("foo" )
@@ -687,33 +679,21 @@ def test_isfile_not_readable_file(self):
687679 self .create_file (file_path , perm = 0 )
688680 self .assertTrue (self .os .path .isfile (file_path ))
689681
690- def check_stat_with_trailing_separator (self , error_nr ):
682+ def test_stat_with_trailing_separator (self ):
691683 # regression test for #376
692684 file_path = self .make_path ("foo" )
693685 self .create_file (file_path )
694- self .assert_raises_os_error (error_nr , self .os .stat , file_path + self .os .sep )
695-
696- def test_stat_with_trailing_separator_posix (self ):
697- self .check_posix_only ()
698- self .check_stat_with_trailing_separator (errno .ENOTDIR )
699-
700- def test_stat_with_trailing_separator_windows (self ):
701- self .check_windows_only ()
702- self .check_stat_with_trailing_separator (errno .EINVAL )
686+ self .assert_raises_os_error (
687+ errno .ENOTDIR , self .os .stat , file_path + self .os .sep
688+ )
703689
704- def check_remove_with_trailing_separator (self , error_nr ):
690+ def test_remove_with_trailing_separator (self ):
705691 # regression test for #377
706692 file_path = self .make_path ("foo" )
707693 self .create_file (file_path )
708- self .assert_raises_os_error (error_nr , self .os .remove , file_path + self .os .sep )
709-
710- def test_remove_with_trailing_separator_posix (self ):
711- self .check_posix_only ()
712- self .check_remove_with_trailing_separator (errno .ENOTDIR )
713-
714- def test_remove_with_trailing_separator_windows (self ):
715- self .check_windows_only ()
716- self .check_remove_with_trailing_separator (errno .EINVAL )
694+ self .assert_raises_os_error (
695+ errno .ENOTDIR , self .os .remove , file_path + self .os .sep
696+ )
717697
718698 def test_readlink (self ):
719699 skip_if_symlink_not_supported ()
@@ -790,7 +770,7 @@ def test_broken_symlink_with_trailing_separator_windows(self):
790770 link_path = self .make_path ("link" )
791771 self .os .symlink (file_path , link_path )
792772 self .assert_raises_os_error (
793- errno .EINVAL ,
773+ errno .ENOTDIR ,
794774 self .os .symlink ,
795775 link_path + self .os .sep ,
796776 link_path + self .os .sep ,
@@ -819,7 +799,7 @@ def test_circular_readlink_with_trailing_separator_windows(self):
819799 file_path = self .make_path ("foo" )
820800 self .os .symlink (file_path , file_path )
821801 self .assert_raises_os_error (
822- errno .EINVAL , self .os .readlink , file_path + self .os .sep
802+ errno .ENOTDIR , self .os .readlink , file_path + self .os .sep
823803 )
824804
825805 def test_readlink_with_links_in_path (self ):
@@ -1125,7 +1105,7 @@ def test_rename_with_target_parent_file_raises_windows(self):
11251105 file_path = self .make_path ("foo" , "baz" )
11261106 self .create_file (file_path )
11271107 self .assert_raises_os_error (
1128- errno .EACCES ,
1108+ errno .EINVAL ,
11291109 self .os .rename ,
11301110 file_path ,
11311111 self .os .path .join (file_path , "new" ),
@@ -2449,7 +2429,7 @@ def test_broken_symlink_with_trailing_sep_windows(self):
24492429 self .check_windows_only ()
24502430 skip_if_symlink_not_supported ()
24512431 path0 = self .make_path ("foo" ) + self .os .sep
2452- self .assert_raises_os_error (errno .EINVAL , self .os .symlink , path0 , path0 )
2432+ self .assert_raises_os_error (errno .ENOTDIR , self .os .symlink , path0 , path0 )
24532433
24542434 def test_rename_symlink_with_trailing_sep_linux (self ):
24552435 # Regression test for #391
@@ -2509,7 +2489,7 @@ def test_lstat_broken_link_with_trailing_sep_macos(self):
25092489 def test_lstat_broken_link_with_trailing_sep_windows (self ):
25102490 self .check_windows_only ()
25112491 link_path = self .create_broken_link_path_with_trailing_sep ()
2512- self .assert_raises_os_error (errno .EINVAL , self .os .lstat , link_path )
2492+ self .assert_raises_os_error (errno .ENOTDIR , self .os .lstat , link_path )
25132493
25142494 def test_mkdir_broken_link_with_trailing_sep_linux_windows (self ):
25152495 self .check_linux_and_windows ()
@@ -2540,7 +2520,7 @@ def test_remove_broken_link_with_trailing_sep_macos(self):
25402520 def test_remove_broken_link_with_trailing_sep_windows (self ):
25412521 self .check_windows_only ()
25422522 link_path = self .create_broken_link_path_with_trailing_sep ()
2543- self .assert_raises_os_error (errno .EINVAL , self .os .remove , link_path )
2523+ self .assert_raises_os_error (errno .ENOTDIR , self .os .remove , link_path )
25442524
25452525 def test_rename_broken_link_with_trailing_sep_linux (self ):
25462526 self .check_linux_only ()
@@ -2560,7 +2540,7 @@ def test_rename_broken_link_with_trailing_sep_windows(self):
25602540 self .check_windows_only ()
25612541 link_path = self .create_broken_link_path_with_trailing_sep ()
25622542 self .assert_raises_os_error (
2563- errno .EINVAL , self .os .rename , link_path , self .make_path ("target" )
2543+ errno .ENOTDIR , self .os .rename , link_path , self .make_path ("target" )
25642544 )
25652545
25662546 def test_readlink_broken_link_with_trailing_sep_posix (self ):
@@ -2571,7 +2551,7 @@ def test_readlink_broken_link_with_trailing_sep_posix(self):
25712551 def test_readlink_broken_link_with_trailing_sep_windows (self ):
25722552 self .check_windows_only ()
25732553 link_path = self .create_broken_link_path_with_trailing_sep ()
2574- self .assert_raises_os_error (errno .EINVAL , self .os .readlink , link_path )
2554+ self .assert_raises_os_error (errno .ENOTDIR , self .os .readlink , link_path )
25752555
25762556 def test_islink_broken_link_with_trailing_sep (self ):
25772557 link_path = self .create_broken_link_path_with_trailing_sep ()
@@ -2618,24 +2598,16 @@ def test_open_broken_symlink_to_path_with_trailing_sep_windows(self):
26182598 self .check_windows_only ()
26192599 self .check_open_broken_symlink_to_path_with_trailing_sep (errno .EINVAL )
26202600
2621- def check_link_path_ending_with_sep (self , error ):
2601+ def test_link_path_ending_with_sep (self ):
26222602 # Regression tests for #399
26232603 skip_if_symlink_not_supported ()
26242604 file_path = self .make_path ("foo" )
26252605 link_path = self .make_path ("link" )
26262606 with self .open (file_path , "w" , encoding = "utf8" ):
26272607 self .assert_raises_os_error (
2628- error , self .os .link , file_path + self .os .sep , link_path
2608+ errno . ENOTDIR , self .os .link , file_path + self .os .sep , link_path
26292609 )
26302610
2631- def test_link_path_ending_with_sep_posix (self ):
2632- self .check_posix_only ()
2633- self .check_link_path_ending_with_sep (errno .ENOTDIR )
2634-
2635- def test_link_path_ending_with_sep_windows (self ):
2636- self .check_windows_only ()
2637- self .check_link_path_ending_with_sep (errno .EINVAL )
2638-
26392611 def test_link_to_path_ending_with_sep_posix (self ):
26402612 # regression test for #407
26412613 self .check_posix_only ()
@@ -2653,22 +2625,14 @@ def test_link_to_path_ending_with_sep_windows(self):
26532625 self .os .link (path1 , path0 )
26542626 self .assertTrue (self .os .path .exists (path1 ))
26552627
2656- def check_rename_to_path_ending_with_sep (self , error ):
2628+ def test_rename_to_path_ending_with_sep (self ):
26572629 # Regression tests for #400
26582630 file_path = self .make_path ("foo" )
26592631 with self .open (file_path , "w" , encoding = "utf8" ):
26602632 self .assert_raises_os_error (
2661- error , self .os .rename , file_path + self .os .sep , file_path
2633+ errno . ENOTDIR , self .os .rename , file_path + self .os .sep , file_path
26622634 )
26632635
2664- def test_rename_to_path_ending_with_sep_posix (self ):
2665- self .check_posix_only ()
2666- self .check_rename_to_path_ending_with_sep (errno .ENOTDIR )
2667-
2668- def test_rename_to_path_ending_with_sep_windows (self ):
2669- self .check_windows_only ()
2670- self .check_rename_to_path_ending_with_sep (errno .EINVAL )
2671-
26722636 def test_rmdir_link_with_trailing_sep_linux (self ):
26732637 self .check_linux_only ()
26742638 dir_path = self .make_path ("foo" )
@@ -2723,7 +2687,9 @@ def test_readlink_circular_link_with_trailing_sep_windows(self):
27232687 path0 = self .make_path ("bar" )
27242688 self .os .symlink (path0 , path1 )
27252689 self .os .symlink (path1 , path0 )
2726- self .assert_raises_os_error (errno .EINVAL , self .os .readlink , path0 + self .os .sep )
2690+ self .assert_raises_os_error (
2691+ errno .ENOTDIR , self .os .readlink , path0 + self .os .sep
2692+ )
27272693
27282694 # hard link related tests
27292695 def test_link_bogus (self ):
@@ -3510,7 +3476,7 @@ def test_rename_with_target_parent_file_raises_windows(self):
35103476 file_path = self .make_path ("foo" , "baz" )
35113477 self .create_file (file_path )
35123478 self .assert_raises_os_error (
3513- errno .EACCES ,
3479+ errno .EINVAL ,
35143480 self .os .rename ,
35153481 file_path ,
35163482 self .os .path .join (file_path .upper (), "new" ),
0 commit comments