MCPcopy
hub / github.com/pytest-dev/pytest / open

Method open

src/_pytest/_py/path.py:749–763  ·  src/_pytest/_py/path.py::LocalPath.open

Return an opened file with the given mode. If ensure is True, create parent directories if needed.

(self, mode="r", ensure=False, encoding=None)

Source from the content-addressed store, hash-verified

747 return obj
748
749 def open(self, mode=class="st">"r", ensure=False, encoding=None):
750 class="st">"""Return an opened file with the given mode.
751
752 If ensure is True, create parent directories if needed.
753 class="st">"""
754 if ensure:
755 self.dirpath().ensure(dir=1)
756 if encoding:
757 return error.checked_call(
758 io.open,
759 self.strpath,
760 mode,
761 encoding=encoding,
762 )
763 return error.checked_call(open, self.strpath, mode)
764
765 def _fastjoin(self, name):
766 child = object.__new__(self.__class__)

Callers 15

read_binaryMethod · 0.95
read_textMethod · 0.95
readMethod · 0.95
readlinesMethod · 0.95
loadMethod · 0.95
computehashMethod · 0.95
dumpMethod · 0.95
write_binaryMethod · 0.95
write_textMethod · 0.95
writeMethod · 0.95
set_log_pathMethod · 0.80
create_cleanup_lockFunction · 0.80

Calls 3

dirpathMethod · 0.95
ensureMethod · 0.80
checked_callMethod · 0.80

Tested by 10

runMethod · 0.64
spawnMethod · 0.64
collectMethod · 0.64
tmpfileFunction · 0.64
schemaFunction · 0.64
__call__Method · 0.64
test_open_and_ensureMethod · 0.64
test_dumpMethod · 0.64