Skip to content

Commit 3c6d906

Browse files
committed
#413 Improve parent directory tests expectations for Windows
* test a posix version of the paths for portable assertions Signed-off-by: Philippe Ombredanne <[email protected]>
1 parent 2b39c06 commit 3c6d906

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

tests/commoncode/test_fileutils.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -671,87 +671,117 @@ def test_parent_directory_on_path_and_location_1(self):
671671
test_file = 'a/.a/file'
672672
expected_name = 'a/.a/'
673673
result = fileutils.parent_directory(test_file)
674+
result = fileutils.as_posixpath(result)
674675
assert expected_name == result
676+
675677
result = fileutils.parent_directory((os.path.join(test_dir, test_file)))
678+
result = fileutils.as_posixpath(result)
676679
assert result.endswith(expected_name)
677680

678681
def test_parent_directory_on_path_and_location_2(self):
679682
test_dir = self.get_test_loc('fileutils/basename')
680683
test_file = 'a/.a/'
681684
expected_name = 'a/'
682685
result = fileutils.parent_directory(test_file)
686+
result = fileutils.as_posixpath(result)
683687
assert expected_name == result
688+
684689
result = fileutils.parent_directory((os.path.join(test_dir, test_file)))
690+
result = fileutils.as_posixpath(result)
685691
assert result.endswith(expected_name)
686692

687693
def test_parent_directory_on_path_and_location_3(self):
688694
test_dir = self.get_test_loc('fileutils/basename')
689695
test_file = 'a/b/.a.b'
690696
expected_name = 'a/b/'
691697
result = fileutils.parent_directory(test_file)
698+
result = fileutils.as_posixpath(result)
692699
assert expected_name == result
700+
693701
result = fileutils.parent_directory((os.path.join(test_dir, test_file)))
702+
result = fileutils.as_posixpath(result)
694703
assert result.endswith(expected_name)
695704

696705
def test_parent_directory_on_path_and_location_4(self):
697706
test_dir = self.get_test_loc('fileutils/basename')
698707
test_file = 'a/b/a.tag.gz'
699708
expected_name = 'a/b/'
700709
result = fileutils.parent_directory(test_file)
710+
result = fileutils.as_posixpath(result)
701711
assert expected_name == result
712+
702713
result = fileutils.parent_directory((os.path.join(test_dir, test_file)))
714+
result = fileutils.as_posixpath(result)
703715
assert result.endswith(expected_name)
704716

705717
def test_parent_directory_on_path_and_location_5(self):
706718
test_dir = self.get_test_loc('fileutils/basename')
707719
test_file = 'a/b/'
708720
expected_name = 'a/'
709721
result = fileutils.parent_directory(test_file)
722+
result = fileutils.as_posixpath(result)
710723
assert expected_name == result
724+
711725
result = fileutils.parent_directory((os.path.join(test_dir, test_file)))
726+
result = fileutils.as_posixpath(result)
712727
assert result.endswith(expected_name)
713728

714729
def test_parent_directory_on_path_and_location_6(self):
715730
test_dir = self.get_test_loc('fileutils/basename')
716731
test_file = 'a/f.a'
717732
expected_name = 'a/'
718733
result = fileutils.parent_directory(test_file)
734+
result = fileutils.as_posixpath(result)
719735
assert expected_name == result
736+
720737
result = fileutils.parent_directory((os.path.join(test_dir, test_file)))
738+
result = fileutils.as_posixpath(result)
721739
assert result.endswith(expected_name)
722740

723741
def test_parent_directory_on_path_and_location_7(self):
724742
test_dir = self.get_test_loc('fileutils/basename')
725743
test_file = 'a/'
726744
expected_name = '/'
727745
result = fileutils.parent_directory(test_file)
746+
result = fileutils.as_posixpath(result)
728747
assert expected_name == result
748+
729749
result = fileutils.parent_directory((os.path.join(test_dir, test_file)))
750+
result = fileutils.as_posixpath(result)
730751
assert result.endswith(expected_name)
731752

732753
def test_parent_directory_on_path_and_location_8(self):
733754
test_dir = self.get_test_loc('fileutils/basename')
734755
test_file = 'f.a/a.c'
735756
expected_name = 'f.a/'
736757
result = fileutils.parent_directory(test_file)
758+
result = fileutils.as_posixpath(result)
737759
assert expected_name == result
760+
738761
result = fileutils.parent_directory((os.path.join(test_dir, test_file)))
762+
result = fileutils.as_posixpath(result)
739763
assert result.endswith(expected_name)
740764

741765
def test_parent_directory_on_path_and_location_9(self):
742766
test_dir = self.get_test_loc('fileutils/basename')
743767
test_file = 'f.a/'
744768
expected_name = '/'
745769
result = fileutils.parent_directory(test_file)
770+
result = fileutils.as_posixpath(result)
746771
assert expected_name == result
772+
747773
result = fileutils.parent_directory((os.path.join(test_dir, test_file)))
774+
result = fileutils.as_posixpath(result)
748775
assert result.endswith(expected_name)
749776

750777
def test_parent_directory_on_path_and_location_10(self):
751778
test_dir = self.get_test_loc('fileutils/basename')
752779
test_file = 'tst'
753780
expected_name = '/'
754781
result = fileutils.parent_directory(test_file)
782+
result = fileutils.as_posixpath(result)
755783
assert expected_name == result
784+
756785
result = fileutils.parent_directory((os.path.join(test_dir, test_file)))
786+
result = fileutils.as_posixpath(result)
757787
assert result.endswith(expected_name)

0 commit comments

Comments
 (0)