| 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() |