MCPcopy Index your code
hub / github.com/RustPython/RustPython / test_absolute_common

Method test_absolute_common

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

Source from the content-addressed store, hash-verified

1231 self._test_cwd(p)
1232
1233 def test_absolute_common(self):
1234 P = self.cls
1235
1236 with mock.patch("os.getcwd") as getcwd:
1237 getcwd.return_value = self.base
1238
1239 # Simple relative paths.
1240 self.assertEqual(str(P().absolute()), self.base)
1241 self.assertEqual(str(P('.').absolute()), self.base)
1242 self.assertEqual(str(P('a').absolute()), os.path.join(self.base, 'a'))
1243 self.assertEqual(str(P('a', 'b', 'c').absolute()), os.path.join(self.base, 'a', 'b', 'c'))
1244
1245 # Symlinks should not be resolved.
1246 self.assertEqual(str(P('linkB', 'fileB').absolute()), os.path.join(self.base, 'linkB', 'fileB'))
1247 self.assertEqual(str(P('brokenLink').absolute()), os.path.join(self.base, 'brokenLink'))
1248 self.assertEqual(str(P('brokenLinkLoop').absolute()), os.path.join(self.base, 'brokenLinkLoop'))
1249
1250 # '..' entries should be preserved and not normalised.
1251 self.assertEqual(str(P('..').absolute()), os.path.join(self.base, '..'))
1252 self.assertEqual(str(P('a', '..').absolute()), os.path.join(self.base, 'a', '..'))
1253 self.assertEqual(str(P('..', 'b').absolute()), os.path.join(self.base, '..', 'b'))
1254
1255 def _test_home(self, p):
1256 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