Skip to content

Commit 2b5673e

Browse files
committed
Drop backport of extra tests that don't really address security concerns.
1 parent f5f9555 commit 2b5673e

File tree

1 file changed

+0
-101
lines changed

1 file changed

+0
-101
lines changed

Lib/test/test_posixpath.py

Lines changed: 0 additions & 101 deletions
Original file line numberDiff line numberDiff line change
@@ -868,107 +868,6 @@ def test_realpath_unreadable_directory(self):
868868
safe_rmdir(ABSTFN + '/k')
869869
safe_rmdir(ABSTFN)
870870

871-
@skip_if_ABSTFN_contains_backslash
872-
def test_realpath_nonterminal_file(self):
873-
try:
874-
with open(ABSTFN, 'w') as f:
875-
f.write('test_posixpath wuz ere')
876-
self.assertEqual(realpath(ABSTFN, strict=False), ABSTFN)
877-
self.assertEqual(realpath(ABSTFN, strict=True), ABSTFN)
878-
self.assertEqual(realpath(ABSTFN, strict=ALLOW_MISSING), ABSTFN)
879-
880-
self.assertEqual(realpath(ABSTFN + "/", strict=False), ABSTFN)
881-
self.assertRaises(NotADirectoryError, realpath, ABSTFN + "/", strict=True)
882-
self.assertRaises(NotADirectoryError, realpath, ABSTFN + "/",
883-
strict=ALLOW_MISSING)
884-
885-
self.assertEqual(realpath(ABSTFN + "/.", strict=False), ABSTFN)
886-
self.assertRaises(NotADirectoryError, realpath, ABSTFN + "/.", strict=True)
887-
self.assertRaises(NotADirectoryError, realpath, ABSTFN + "/.",
888-
strict=ALLOW_MISSING)
889-
890-
self.assertEqual(realpath(ABSTFN + "/..", strict=False), dirname(ABSTFN))
891-
self.assertRaises(NotADirectoryError, realpath, ABSTFN + "/..", strict=True)
892-
self.assertRaises(NotADirectoryError, realpath, ABSTFN + "/..",
893-
strict=ALLOW_MISSING)
894-
895-
self.assertEqual(realpath(ABSTFN + "/subdir", strict=False), ABSTFN + "/subdir")
896-
self.assertRaises(NotADirectoryError, realpath, ABSTFN + "/subdir", strict=True)
897-
self.assertRaises(NotADirectoryError, realpath, ABSTFN + "/subdir",
898-
strict=ALLOW_MISSING)
899-
finally:
900-
os_helper.unlink(ABSTFN)
901-
902-
@os_helper.skip_unless_symlink
903-
@skip_if_ABSTFN_contains_backslash
904-
def test_realpath_nonterminal_symlink_to_file(self):
905-
try:
906-
with open(ABSTFN + "1", 'w') as f:
907-
f.write('test_posixpath wuz ere')
908-
os.symlink(ABSTFN + "1", ABSTFN)
909-
self.assertEqual(realpath(ABSTFN, strict=False), ABSTFN + "1")
910-
self.assertEqual(realpath(ABSTFN, strict=True), ABSTFN + "1")
911-
self.assertEqual(realpath(ABSTFN, strict=ALLOW_MISSING), ABSTFN + "1")
912-
913-
self.assertEqual(realpath(ABSTFN + "/", strict=False), ABSTFN + "1")
914-
self.assertRaises(NotADirectoryError, realpath, ABSTFN + "/", strict=True)
915-
self.assertRaises(NotADirectoryError, realpath, ABSTFN + "/",
916-
strict=ALLOW_MISSING)
917-
918-
self.assertEqual(realpath(ABSTFN + "/.", strict=False), ABSTFN + "1")
919-
self.assertRaises(NotADirectoryError, realpath, ABSTFN + "/.", strict=True)
920-
self.assertRaises(NotADirectoryError, realpath, ABSTFN + "/.",
921-
strict=ALLOW_MISSING)
922-
923-
self.assertEqual(realpath(ABSTFN + "/..", strict=False), dirname(ABSTFN))
924-
self.assertRaises(NotADirectoryError, realpath, ABSTFN + "/..", strict=True)
925-
self.assertRaises(NotADirectoryError, realpath, ABSTFN + "/..",
926-
strict=ALLOW_MISSING)
927-
928-
self.assertEqual(realpath(ABSTFN + "/subdir", strict=False), ABSTFN + "1/subdir")
929-
self.assertRaises(NotADirectoryError, realpath, ABSTFN + "/subdir", strict=True)
930-
self.assertRaises(NotADirectoryError, realpath, ABSTFN + "/subdir",
931-
strict=ALLOW_MISSING)
932-
finally:
933-
os_helper.unlink(ABSTFN)
934-
os_helper.unlink(ABSTFN + "1")
935-
936-
@os_helper.skip_unless_symlink
937-
@skip_if_ABSTFN_contains_backslash
938-
def test_realpath_nonterminal_symlink_to_symlinks_to_file(self):
939-
try:
940-
with open(ABSTFN + "2", 'w') as f:
941-
f.write('test_posixpath wuz ere')
942-
os.symlink(ABSTFN + "2", ABSTFN + "1")
943-
os.symlink(ABSTFN + "1", ABSTFN)
944-
self.assertEqual(realpath(ABSTFN, strict=False), ABSTFN + "2")
945-
self.assertEqual(realpath(ABSTFN, strict=True), ABSTFN + "2")
946-
self.assertEqual(realpath(ABSTFN, strict=True), ABSTFN + "2")
947-
948-
self.assertEqual(realpath(ABSTFN + "/", strict=False), ABSTFN + "2")
949-
self.assertRaises(NotADirectoryError, realpath, ABSTFN + "/", strict=True)
950-
self.assertRaises(NotADirectoryError, realpath, ABSTFN + "/",
951-
strict=ALLOW_MISSING)
952-
953-
self.assertEqual(realpath(ABSTFN + "/.", strict=False), ABSTFN + "2")
954-
self.assertRaises(NotADirectoryError, realpath, ABSTFN + "/.", strict=True)
955-
self.assertRaises(NotADirectoryError, realpath, ABSTFN + "/.",
956-
strict=ALLOW_MISSING)
957-
958-
self.assertEqual(realpath(ABSTFN + "/..", strict=False), dirname(ABSTFN))
959-
self.assertRaises(NotADirectoryError, realpath, ABSTFN + "/..", strict=True)
960-
self.assertRaises(NotADirectoryError, realpath, ABSTFN + "/..",
961-
strict=ALLOW_MISSING)
962-
963-
self.assertEqual(realpath(ABSTFN + "/subdir", strict=False), ABSTFN + "2/subdir")
964-
self.assertRaises(NotADirectoryError, realpath, ABSTFN + "/subdir", strict=True)
965-
self.assertRaises(NotADirectoryError, realpath, ABSTFN + "/subdir",
966-
strict=ALLOW_MISSING)
967-
finally:
968-
os_helper.unlink(ABSTFN)
969-
os_helper.unlink(ABSTFN + "1")
970-
os_helper.unlink(ABSTFN + "2")
971-
972871
def test_relpath(self):
973872
(real_getcwd, os.getcwd) = (os.getcwd, lambda: r"/home/user/bar")
974873
try:

0 commit comments

Comments
 (0)