mirror of
https://github.com/python/cpython.git
synced 2025-08-03 16:39:00 +00:00
bpo-32695: Docs and tests for compresslevel and preset kwargs in tarfile (GH-21470)
Co-Authored-By: Bo Bayles <bbayles@gmail.com>
This commit is contained in:
parent
ac75f6bdd4
commit
eb2d4a66ff
3 changed files with 23 additions and 3 deletions
|
@ -1706,15 +1706,30 @@ class CreateTest(WriteTestBase, unittest.TestCase):
|
|||
|
||||
|
||||
class GzipCreateTest(GzipTest, CreateTest):
|
||||
pass
|
||||
|
||||
def test_create_with_compresslevel(self):
|
||||
with tarfile.open(tmpname, self.mode, compresslevel=1) as tobj:
|
||||
tobj.add(self.file_path)
|
||||
with tarfile.open(tmpname, 'r:gz', compresslevel=1) as tobj:
|
||||
pass
|
||||
|
||||
|
||||
class Bz2CreateTest(Bz2Test, CreateTest):
|
||||
pass
|
||||
|
||||
def test_create_with_compresslevel(self):
|
||||
with tarfile.open(tmpname, self.mode, compresslevel=1) as tobj:
|
||||
tobj.add(self.file_path)
|
||||
with tarfile.open(tmpname, 'r:bz2', compresslevel=1) as tobj:
|
||||
pass
|
||||
|
||||
|
||||
class LzmaCreateTest(LzmaTest, CreateTest):
|
||||
pass
|
||||
|
||||
# Unlike gz and bz2, xz uses the preset keyword instead of compresslevel.
|
||||
# It does not allow for preset to be specified when reading.
|
||||
def test_create_with_preset(self):
|
||||
with tarfile.open(tmpname, self.mode, preset=1) as tobj:
|
||||
tobj.add(self.file_path)
|
||||
|
||||
|
||||
class CreateWithXModeTest(CreateTest):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue