Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(200192)

Unified Diff: Lib/test/test_tarfile.py

Issue 23421: tarfile module does not correctly choose compression algorithms
Patch Set: Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
--- a/Lib/test/test_tarfile.py
+++ b/Lib/test/test_tarfile.py
@@ -33,6 +33,10 @@
xzname = os.path.join(TEMPDIR, "testtar.tar.xz")
tmpname = os.path.join(TEMPDIR, "tmp.tar")
dotlessname = os.path.join(TEMPDIR, "testtar")
+clitarname = os.path.join(TEMPDIR, "clitar.tar")
+cligzipname = os.path.join(TEMPDIR, "clitar.tar.gz")
+clibz2name = os.path.join(TEMPDIR, "clitar.tar.bz2")
+clixzname = os.path.join(TEMPDIR, "clitar.tar.xz")
md5_regtype = "65f477c818ad9e15f7feab0c6d37742f"
md5_sparse = "a54fbc4ca4f4399a90e1b27164012fc6"
@@ -40,6 +44,7 @@
class TarTest:
tarname = tarname
+ clitarname = clitarname
suffix = ''
open = io.FileIO
taropen = tarfile.TarFile.taropen
@@ -51,6 +56,7 @@
@support.requires_gzip
class GzipTest:
tarname = gzipname
+ clitarname = cligzipname
suffix = 'gz'
open = gzip.GzipFile if gzip else None
taropen = tarfile.TarFile.gzopen
@@ -58,6 +64,7 @@
@support.requires_bz2
class Bz2Test:
tarname = bz2name
+ clitarname = clibz2name
suffix = 'bz2'
open = bz2.BZ2File if bz2 else None
taropen = tarfile.TarFile.bz2open
@@ -65,6 +72,7 @@
@support.requires_lzma
class LzmaTest:
tarname = xzname
+ clitarname = clixzname
suffix = 'xz'
open = lzma.LZMAFile if lzma else None
taropen = tarfile.TarFile.xzopen
@@ -2006,6 +2014,21 @@
finally:
support.unlink(tar_name)
+ def test_create_command_filetype(self):
+ files = [support.findfile('tokenize_tests.txt'),
+ support.findfile('tokenize_tests-no-coding-cookie-'
+ 'and-utf8-bom-sig-only.txt')]
+
+ for filetype in (TarTest, GzipTest, Bz2Test, LzmaTest):
storchaka 2015/02/09 19:33:45 Uncompressed tar files already tested in other tes
+ for opt in '-c', '--create':
storchaka 2015/02/09 19:33:45 The long option already tested in other test. This
+ try:
+ out = self.tarfilecmd(opt, filetype.clitarname, *files)
storchaka 2015/02/09 19:33:45 Compression can be not available if required modul
+ self.assertEqual(out, b'')
+ with filetype.taropen(filetype.clitarname, "r") as tar:
+ pass
+ finally:
+ support.unlink(filetype.clitarname)
+
def test_extract_command(self):
self.make_simple_tarfile(tmpname)
for opt in '-e', '--extract':
« no previous file with comments | « no previous file | no next file » | no next file with comments »

RSS Feeds Recent Issues | This issue
This is Rietveld 894c83f36cb7+