| 3073 | |
| 3074 | class UnseekableTests(unittest.TestCase): |
| 3075 | def test_writestr(self): |
| 3076 | for wrapper in (lambda f: f), Tellable, Unseekable: |
| 3077 | with self.subTest(wrapper=wrapper): |
| 3078 | f = io.BytesIO() |
| 3079 | f.write(b'abc') |
| 3080 | bf = io.BufferedWriter(f) |
| 3081 | with zipfile.ZipFile(wrapper(bf), 'w', zipfile.ZIP_STORED) as zipfp: |
| 3082 | zipfp.writestr('ones', b'111') |
| 3083 | zipfp.writestr('twos', b'222') |
| 3084 | self.assertEqual(f.getvalue()[:5], b'abcPK') |
| 3085 | with zipfile.ZipFile(f, mode='r') as zipf: |
| 3086 | with zipf.open('ones') as zopen: |
| 3087 | self.assertEqual(zopen.read(), b'111') |
| 3088 | with zipf.open('twos') as zopen: |
| 3089 | self.assertEqual(zopen.read(), b'222') |
| 3090 | |
| 3091 | def test_write(self): |
| 3092 | for wrapper in (lambda f: f), Tellable, Unseekable: |