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

Method test_with_segments

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

Source from the content-addressed store, hash-verified

1282 self.assertEqual(p.expanduser(), P(os.path.expanduser('~'), './a:b'))
1283
1284 def test_with_segments(self):
1285 class P(self.cls):
1286 def __init__(self, *pathsegments, session_id):
1287 super().__init__(*pathsegments)
1288 self.session_id = session_id
1289
1290 def with_segments(self, *pathsegments):
1291 return type(self)(*pathsegments, session_id=self.session_id)
1292 p = P(self.base, session_id=42)
1293 self.assertEqual(42, p.absolute().session_id)
1294 self.assertEqual(42, p.resolve().session_id)
1295 if not is_wasi: # WASI has no user accounts.
1296 self.assertEqual(42, p.with_segments('~').expanduser().session_id)
1297 self.assertEqual(42, (p / 'fileA').rename(p / 'fileB').session_id)
1298 self.assertEqual(42, (p / 'fileB').replace(p / 'fileA').session_id)
1299 if self.can_symlink:
1300 self.assertEqual(42, (p / 'linkA').readlink().session_id)
1301 for path in p.iterdir():
1302 self.assertEqual(42, path.session_id)
1303 for path in p.glob('*'):
1304 self.assertEqual(42, path.session_id)
1305 for path in p.rglob('*'):
1306 self.assertEqual(42, path.session_id)
1307 for dirpath, dirnames, filenames in p.walk():
1308 self.assertEqual(42, dirpath.session_id)
1309
1310 def test_open_common(self):
1311 p = self.cls(self.base)

Callers

nothing calls this directly

Calls 13

with_segmentsMethod · 0.95
absoluteMethod · 0.80
expanduserMethod · 0.80
PClass · 0.70
assertEqualMethod · 0.45
resolveMethod · 0.45
renameMethod · 0.45
replaceMethod · 0.45
readlinkMethod · 0.45
iterdirMethod · 0.45
globMethod · 0.45
rglobMethod · 0.45

Tested by

no test coverage detected