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

Method test_with_segments

Lib/test/test_pathlib/test_join.py:36–54  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

34 P('/a/b/c')
35
36 def test_with_segments(self):
37 class P(self.cls):
38 def __init__(self, *pathsegments, session_id):
39 super().__init__(*pathsegments)
40 self.session_id = session_id
41
42 def with_segments(self, *pathsegments):
43 return type(self)(*pathsegments, session_id=self.session_id)
44 p = P('foo', 'bar', session_id=42)
45 self.assertEqual(42, (p / 'foo').session_id)
46 self.assertEqual(42, ('foo' / p).session_id)
47 self.assertEqual(42, p.joinpath('foo').session_id)
48 self.assertEqual(42, p.with_name('foo').session_id)
49 self.assertEqual(42, p.with_stem('foo').session_id)
50 self.assertEqual(42, p.with_suffix('.foo').session_id)
51 self.assertEqual(42, p.with_segments('foo').session_id)
52 self.assertEqual(42, p.parent.session_id)
53 for parent in p.parents:
54 self.assertEqual(42, parent.session_id)
55
56 def test_join(self):
57 P = self.cls

Callers

nothing calls this directly

Calls 7

with_segmentsMethod · 0.95
PClass · 0.70
assertEqualMethod · 0.45
joinpathMethod · 0.45
with_nameMethod · 0.45
with_stemMethod · 0.45
with_suffixMethod · 0.45

Tested by

no test coverage detected