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

Method test_writestr

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

Source from the content-addressed store, hash-verified

2942
2943class UnseekableTests(unittest.TestCase):
2944 def test_writestr(self):
2945 for wrapper in (lambda f: f), Tellable, Unseekable:
2946 with self.subTest(wrapper=wrapper):
2947 f = io.BytesIO()
2948 f.write(b'abc')
2949 bf = io.BufferedWriter(f)
2950 with zipfile.ZipFile(wrapper(bf), 'w', zipfile.ZIP_STORED) as zipfp:
2951 zipfp.writestr('ones', b'111')
2952 zipfp.writestr('twos', b'222')
2953 self.assertEqual(f.getvalue()[:5], b'abcPK')
2954 with zipfile.ZipFile(f, mode='r') as zipf:
2955 with zipf.open('ones') as zopen:
2956 self.assertEqual(zopen.read(), b'111')
2957 with zipf.open('twos') as zopen:
2958 self.assertEqual(zopen.read(), b'222')
2959
2960 def test_write(self):
2961 for wrapper in (lambda f: f), Tellable, Unseekable:

Callers

nothing calls this directly

Calls 8

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

Tested by

no test coverage detected