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

Function _load_testfile

Lib/doctest.py:245–261  ·  view source on GitHub ↗
(filename, package, module_relative, encoding)

Source from the content-addressed store, hash-verified

243 return IncrementalNewlineDecoder(None, True).decode(data, True)
244
245def _load_testfile(filename, package, module_relative, encoding):
246 if module_relative:
247 package = _normalize_module(package, 3)
248 filename = _module_relative_path(package, filename)
249 if (loader := getattr(package, '__loader__', None)) is None:
250 try:
251 loader = package.__spec__.loader
252 except AttributeError:
253 pass
254 if hasattr(loader, 'get_data'):
255 file_contents = loader.get_data(filename)
256 file_contents = file_contents.decode(encoding)
257 # get_data() opens files as 'rb', so one must do the equivalent
258 # conversion as universal newlines would do.
259 return _newline_convert(file_contents), filename
260 with open(filename, encoding=encoding) as f:
261 return f.read(), filename
262
263def _indent(s, indent=4):
264 """

Callers 2

testfileFunction · 0.85
DocFileTestFunction · 0.85

Calls 9

_normalize_moduleFunction · 0.85
_module_relative_pathFunction · 0.85
getattrFunction · 0.85
hasattrFunction · 0.85
_newline_convertFunction · 0.85
openFunction · 0.70
get_dataMethod · 0.45
decodeMethod · 0.45
readMethod · 0.45

Tested by

no test coverage detected