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

Method test_open_write

Lib/test/test_zipfile/test_core.py:3112–3126  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

3110 self.assertEqual(zopen.read(), b'222')
3111
3112 def test_open_write(self):
3113 for wrapper in (lambda f: f), Tellable, Unseekable:
3114 with self.subTest(wrapper=wrapper):
3115 f = io.BytesIO()
3116 f.write(b'abc')
3117 bf = io.BufferedWriter(f)
3118 with zipfile.ZipFile(wrapper(bf), 'w', zipfile.ZIP_STORED) as zipf:
3119 with zipf.open('ones', 'w') as zopen:
3120 zopen.write(b'111')
3121 with zipf.open('twos', 'w') as zopen:
3122 zopen.write(b'222')
3123 self.assertEqual(f.getvalue()[:5], b'abcPK')
3124 with zipfile.ZipFile(f) as zipf:
3125 self.assertEqual(zipf.read('ones'), b'111')
3126 self.assertEqual(zipf.read('twos'), b'222')
3127
3128
3129@requires_zlib()

Callers

nothing calls this directly

Calls 8

writeMethod · 0.95
getvalueMethod · 0.95
wrapperFunction · 0.50
subTestMethod · 0.45
openMethod · 0.45
writeMethod · 0.45
assertEqualMethod · 0.45
readMethod · 0.45

Tested by

no test coverage detected