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

Method write_binary

src/_pytest/_py/path.py:892–899  ·  src/_pytest/_py/path.py::LocalPath.write_binary

Write binary data into path. If ensure is True create missing parent directories.

(self, data, ensure=False)

Source from the content-addressed store, hash-verified

890 return p
891
892 def write_binary(self, data, ensure=False):
893 class="st">"""Write binary data into path. If ensure is True create
894 missing parent directories.
895 class="st">"""
896 if ensure:
897 self.dirpath().ensure(dir=1)
898 with self.open(class="st">"wb") as f:
899 f.write(data)
900
901 def write_text(self, data, encoding, ensure=False):
902 class="st">"""Write text data into path using the specified encoding.

Callers 1

test_read_binwriteMethod · 0.80

Calls 4

dirpathMethod · 0.95
openMethod · 0.95
ensureMethod · 0.80
writeMethod · 0.45

Tested by 1

test_read_binwriteMethod · 0.64