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

Method _get_pth_lines

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

Source from the content-addressed store, hash-verified

708 return sys_path
709
710 def _get_pth_lines(self, libpath: str, *, import_site: bool):
711 pth_lines = ['fake-path-name']
712 # include 200 lines of `libpath` in _pth lines (or fewer
713 # if the `libpath` is long enough to get close to 32KB
714 # see https://github.com/python/cpython/issues/113628)
715 encoded_libpath_length = len(libpath.encode("utf-8"))
716 repetitions = min(200, 30000 // encoded_libpath_length)
717 if repetitions <= 2:
718 self.skipTest(
719 f"Python stdlib path is too long ({encoded_libpath_length:,} bytes)")
720 pth_lines.extend(libpath for _ in range(repetitions))
721 pth_lines.extend(['', '# comment'])
722 if import_site:
723 pth_lines.append('import site')
724 return pth_lines
725
726 @unittest.expectedFailure # TODO: RUSTPYTHON
727 @support.requires_subprocess()

Callers 3

test_underpth_fileMethod · 0.95

Calls 6

lenFunction · 0.85
minFunction · 0.85
skipTestMethod · 0.80
encodeMethod · 0.45
extendMethod · 0.45
appendMethod · 0.45

Tested by

no test coverage detected