MCPcopy Index your code
hub / github.com/python/cpython / test_realpath_nonterminal_file

Method test_realpath_nonterminal_file

Lib/test/test_posixpath.py:897–930  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

895
896 @skip_if_ABSTFN_contains_backslash
897 def test_realpath_nonterminal_file(self):
898 try:
899 with open(ABSTFN, 'w') as f:
900 f.write('test_posixpath wuz ere')
901 self.assertEqual(realpath(ABSTFN, strict=False), ABSTFN)
902 self.assertEqual(realpath(ABSTFN, strict=ALL_BUT_LAST), ABSTFN)
903 self.assertEqual(realpath(ABSTFN, strict=True), ABSTFN)
904 self.assertEqual(realpath(ABSTFN, strict=ALLOW_MISSING), ABSTFN)
905
906 self.assertEqual(realpath(ABSTFN + "/", strict=False), ABSTFN)
907 self.assertRaises(NotADirectoryError, realpath, ABSTFN + "/", strict=ALL_BUT_LAST)
908 self.assertRaises(NotADirectoryError, realpath, ABSTFN + "/", strict=True)
909 self.assertRaises(NotADirectoryError, realpath, ABSTFN + "/",
910 strict=ALLOW_MISSING)
911
912 self.assertEqual(realpath(ABSTFN + "/.", strict=False), ABSTFN)
913 self.assertRaises(NotADirectoryError, realpath, ABSTFN + "/.", strict=ALL_BUT_LAST)
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), dirname(ABSTFN))
919 self.assertRaises(NotADirectoryError, realpath, ABSTFN + "/..", strict=ALL_BUT_LAST)
920 self.assertRaises(NotADirectoryError, realpath, ABSTFN + "/..", strict=True)
921 self.assertRaises(NotADirectoryError, realpath, ABSTFN + "/..",
922 strict=ALLOW_MISSING)
923
924 self.assertEqual(realpath(ABSTFN + "/subdir", strict=False), ABSTFN + "/subdir")
925 self.assertRaises(NotADirectoryError, realpath, ABSTFN + "/subdir", strict=ALL_BUT_LAST)
926 self.assertRaises(NotADirectoryError, realpath, ABSTFN + "/subdir", strict=True)
927 self.assertRaises(NotADirectoryError, realpath, ABSTFN + "/subdir",
928 strict=ALLOW_MISSING)
929 finally:
930 os_helper.unlink(ABSTFN)
931
932 @os_helper.skip_unless_symlink
933 @skip_if_ABSTFN_contains_backslash

Callers

nothing calls this directly

Calls 7

realpathFunction · 0.90
dirnameFunction · 0.90
openFunction · 0.50
writeMethod · 0.45
assertEqualMethod · 0.45
assertRaisesMethod · 0.45
unlinkMethod · 0.45

Tested by

no test coverage detected