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

Method _get_pth_lines

Lib/test/test_site.py:697–711  ·  view source on GitHub ↗
(self, libpath: str, *, import_site: bool)

Source from the content-addressed store, hash-verified

695 return sys_path
696
697 def _get_pth_lines(self, libpath: str, *, import_site: bool):
698 pth_lines = ['fake-path-name']
699 # include 200 lines of `libpath` in _pth lines (or fewer
700 # if the `libpath` is long enough to get close to 32KB
701 # see https://github.com/python/cpython/issues/113628)
702 encoded_libpath_length = len(libpath.encode("utf-8"))
703 repetitions = min(200, 30000 // encoded_libpath_length)
704 if repetitions <= 2:
705 self.skipTest(
706 f"Python stdlib path is too long ({encoded_libpath_length:,} bytes)")
707 pth_lines.extend(libpath for _ in range(repetitions))
708 pth_lines.extend(['', '# comment'])
709 if import_site:
710 pth_lines.append('import site')
711 return pth_lines
712
713 @support.requires_subprocess()
714 def test_underpth_basic(self):

Callers 3

test_underpth_fileMethod · 0.95

Calls 4

skipTestMethod · 0.80
encodeMethod · 0.45
extendMethod · 0.45
appendMethod · 0.45

Tested by

no test coverage detected