MCPcopy Index your code
hub / github.com/RustPython/RustPython / test_open_write

Method test_open_write

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

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 8

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

Tested by

no test coverage detected