(self)
| 2958 | self.assertEqual(zopen.read(), b'222') |
| 2959 | |
| 2960 | def test_write(self): |
| 2961 | for wrapper in (lambda f: f), Tellable, Unseekable: |
| 2962 | with self.subTest(wrapper=wrapper): |
| 2963 | f = io.BytesIO() |
| 2964 | f.write(b'abc') |
| 2965 | bf = io.BufferedWriter(f) |
| 2966 | with zipfile.ZipFile(wrapper(bf), 'w', zipfile.ZIP_STORED) as zipfp: |
| 2967 | self.addCleanup(unlink, TESTFN) |
| 2968 | with open(TESTFN, 'wb') as f2: |
| 2969 | f2.write(b'111') |
| 2970 | zipfp.write(TESTFN, 'ones') |
| 2971 | with open(TESTFN, 'wb') as f2: |
| 2972 | f2.write(b'222') |
| 2973 | zipfp.write(TESTFN, 'twos') |
| 2974 | self.assertEqual(f.getvalue()[:5], b'abcPK') |
| 2975 | with zipfile.ZipFile(f, mode='r') as zipf: |
| 2976 | with zipf.open('ones') as zopen: |
| 2977 | self.assertEqual(zopen.read(), b'111') |
| 2978 | with zipf.open('twos') as zopen: |
| 2979 | self.assertEqual(zopen.read(), b'222') |
| 2980 | |
| 2981 | def test_open_write(self): |
| 2982 | for wrapper in (lambda f: f), Tellable, Unseekable: |
nothing calls this directly
no test coverage detected