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

Method test_write

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

Source from the content-addressed store, hash-verified

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:

Callers

nothing calls this directly

Calls 10

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

Tested by

no test coverage detected