| 2979 | self.assertEqual(zopen.read(), b'222') |
| 2980 | |
| 2981 | def test_open_write(self): |
| 2982 | for wrapper in (lambda f: f), Tellable, Unseekable: |
| 2983 | with self.subTest(wrapper=wrapper): |
| 2984 | f = io.BytesIO() |
| 2985 | f.write(b'abc') |
| 2986 | bf = io.BufferedWriter(f) |
| 2987 | with zipfile.ZipFile(wrapper(bf), 'w', zipfile.ZIP_STORED) as zipf: |
| 2988 | with zipf.open('ones', 'w') as zopen: |
| 2989 | zopen.write(b'111') |
| 2990 | with zipf.open('twos', 'w') as zopen: |
| 2991 | zopen.write(b'222') |
| 2992 | self.assertEqual(f.getvalue()[:5], b'abcPK') |
| 2993 | with zipfile.ZipFile(f) as zipf: |
| 2994 | self.assertEqual(zipf.read('ones'), b'111') |
| 2995 | self.assertEqual(zipf.read('twos'), b'222') |
| 2996 | |
| 2997 | |
| 2998 | @requires_zlib() |