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

Method test_create_command

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

Source from the content-addressed store, hash-verified

3485
3486 @requires_zlib()
3487 def test_create_command(self):
3488 self.addCleanup(unlink, TESTFN)
3489 with open(TESTFN, 'w', encoding='utf-8') as f:
3490 f.write('test 1')
3491 os.mkdir(TESTFNDIR)
3492 self.addCleanup(rmtree, TESTFNDIR)
3493 with open(os.path.join(TESTFNDIR, 'file.txt'), 'w', encoding='utf-8') as f:
3494 f.write('test 2')
3495 files = [TESTFN, TESTFNDIR]
3496 namelist = [TESTFN, TESTFNDIR + '/', TESTFNDIR + '/file.txt']
3497 for opt in '-c', '--create':
3498 try:
3499 out = self.zipfilecmd(opt, TESTFN2, *files)
3500 self.assertEqual(out, b'')
3501 with zipfile.ZipFile(TESTFN2) as zf:
3502 self.assertEqual(zf.namelist(), namelist)
3503 self.assertEqual(zf.read(namelist[0]), b'test 1')
3504 self.assertEqual(zf.read(namelist[2]), b'test 2')
3505 finally:
3506 unlink(TESTFN2)
3507
3508 def test_extract_command(self):
3509 zip_name = findfile('zipdir.zip', subdir='archivetestdata')

Callers

nothing calls this directly

Calls 10

zipfilecmdMethod · 0.95
unlinkFunction · 0.90
addCleanupMethod · 0.80
openFunction · 0.50
writeMethod · 0.45
mkdirMethod · 0.45
joinMethod · 0.45
assertEqualMethod · 0.45
namelistMethod · 0.45
readMethod · 0.45

Tested by

no test coverage detected