diff --git a/Lib/test/test_tarfile.py b/Lib/test/test_tarfile.py --- 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): + for opt in '-c', '--create': + try: + out = self.tarfilecmd(opt, filetype.clitarname, *files) + 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':