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

Method test_absolute_common

Lib/test/test_pathlib/test_pathlib.py:1224–1244  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

1222 self._test_cwd(p)
1223
1224 def test_absolute_common(self):
1225 P = self.cls
1226
1227 with mock.patch("os.getcwd") as getcwd:
1228 getcwd.return_value = self.base
1229
1230 # Simple relative paths.
1231 self.assertEqual(str(P().absolute()), self.base)
1232 self.assertEqual(str(P('.').absolute()), self.base)
1233 self.assertEqual(str(P('a').absolute()), os.path.join(self.base, 'a'))
1234 self.assertEqual(str(P('a', 'b', 'c').absolute()), os.path.join(self.base, 'a', 'b', 'c'))
1235
1236 # Symlinks should not be resolved.
1237 self.assertEqual(str(P('linkB', 'fileB').absolute()), os.path.join(self.base, 'linkB', 'fileB'))
1238 self.assertEqual(str(P('brokenLink').absolute()), os.path.join(self.base, 'brokenLink'))
1239 self.assertEqual(str(P('brokenLinkLoop').absolute()), os.path.join(self.base, 'brokenLinkLoop'))
1240
1241 # '..' entries should be preserved and not normalised.
1242 self.assertEqual(str(P('..').absolute()), os.path.join(self.base, '..'))
1243 self.assertEqual(str(P('a', '..').absolute()), os.path.join(self.base, 'a', '..'))
1244 self.assertEqual(str(P('..', 'b').absolute()), os.path.join(self.base, '..', 'b'))
1245
1246 def _test_home(self, p):
1247 q = self.cls(os.path.expanduser('~'))

Callers

nothing calls this directly

Calls 5

strFunction · 0.85
absoluteMethod · 0.80
PClass · 0.70
assertEqualMethod · 0.45
joinMethod · 0.45

Tested by

no test coverage detected