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

Method test_open_encoding_utf16

Lib/test/test_zipfile/_path/test_path.py:146–159  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

144 self.assertEqual(data, "content of a")
145
146 def test_open_encoding_utf16(self):
147 in_memory_file = io.BytesIO()
148 zf = zipfile.ZipFile(in_memory_file, "w")
149 zf.writestr("path/16.txt", "This was utf-16".encode("utf-16"))
150 zf.filename = "test_open_utf16.zip"
151 root = zipfile.Path(zf)
152 (path,) = root.iterdir()
153 u16 = path.joinpath("16.txt")
154 with u16.open('r', "utf-16") as strm:
155 data = strm.read()
156 assert data == "This was utf-16"
157 with u16.open(encoding="utf-16") as strm:
158 data = strm.read()
159 assert data == "This was utf-16"
160
161 def test_open_encoding_errors(self):
162 in_memory_file = io.BytesIO()

Callers

nothing calls this directly

Calls 6

writestrMethod · 0.95
iterdirMethod · 0.95
encodeMethod · 0.45
joinpathMethod · 0.45
openMethod · 0.45
readMethod · 0.45

Tested by

no test coverage detected