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

Method test_with_segments

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

Source from the content-addressed store, hash-verified

1291 self.assertEqual(p.expanduser(), P(os.path.expanduser('~'), './a:b'))
1292
1293 def test_with_segments(self):
1294 class P(self.cls):
1295 def __init__(self, *pathsegments, session_id):
1296 super().__init__(*pathsegments)
1297 self.session_id = session_id
1298
1299 def with_segments(self, *pathsegments):
1300 return type(self)(*pathsegments, session_id=self.session_id)
1301 p = P(self.base, session_id=42)
1302 self.assertEqual(42, p.absolute().session_id)
1303 self.assertEqual(42, p.resolve().session_id)
1304 if not is_wasi: # WASI has no user accounts.
1305 self.assertEqual(42, p.with_segments('~').expanduser().session_id)
1306 self.assertEqual(42, (p / 'fileA').rename(p / 'fileB').session_id)
1307 self.assertEqual(42, (p / 'fileB').replace(p / 'fileA').session_id)
1308 if self.can_symlink:
1309 self.assertEqual(42, (p / 'linkA').readlink().session_id)
1310 for path in p.iterdir():
1311 self.assertEqual(42, path.session_id)
1312 for path in p.glob('*'):
1313 self.assertEqual(42, path.session_id)
1314 for path in p.rglob('*'):
1315 self.assertEqual(42, path.session_id)
1316 for dirpath, dirnames, filenames in p.walk():
1317 self.assertEqual(42, dirpath.session_id)
1318
1319 def test_open_common(self):
1320 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