[Python-checkins] cpython (2.7): Explicitly test archive name in shutil.make_archive() tests to expose failure
serhiy.storchaka
python-checkins at python.org
Mon Sep 7 12:58:39 CEST 2015
https://hg.python.org/cpython/rev/beda04bf5991
changeset: 97742:beda04bf5991
branch: 2.7
parent: 97737:741b033c5290
user: Serhiy Storchaka <storchaka at gmail.com>
date: Mon Sep 07 13:55:25 2015 +0300
summary:
Explicitly test archive name in shutil.make_archive() tests to expose failure
details in issue25018.
files:
Lib/test/test_shutil.py | 22 +++++++++++-----------
1 files changed, 11 insertions(+), 11 deletions(-)
diff --git a/Lib/test/test_shutil.py b/Lib/test/test_shutil.py
--- a/Lib/test/test_shutil.py
+++ b/Lib/test/test_shutil.py
@@ -385,10 +385,10 @@
base_name = os.path.join(tmpdir2, 'archive')
# working with relative paths to avoid tar warnings
- make_archive(splitdrive(base_name)[1], 'gztar', root_dir, '.')
+ tarball = make_archive(splitdrive(base_name)[1], 'gztar', root_dir, '.')
# check if the compressed tarball was created
- tarball = base_name + '.tar.gz'
+ self.assertEqual(tarball, base_name + '.tar.gz')
self.assertTrue(os.path.isfile(tarball))
self.assertTrue(tarfile.is_tarfile(tarball))
with tarfile.open(tarball, 'r:gz') as tf:
@@ -397,9 +397,8 @@
'./sub', './sub/file3', './sub2'])
# trying an uncompressed one
- base_name = os.path.join(tmpdir2, 'archive')
- make_archive(splitdrive(base_name)[1], 'tar', root_dir, '.')
- tarball = base_name + '.tar'
+ tarball = make_archive(splitdrive(base_name)[1], 'tar', root_dir, '.')
+ self.assertEqual(tarball, base_name + '.tar')
self.assertTrue(os.path.isfile(tarball))
self.assertTrue(tarfile.is_tarfile(tarball))
with tarfile.open(tarball, 'r') as tf:
@@ -434,10 +433,10 @@
def test_tarfile_vs_tar(self):
root_dir, base_dir = self._create_files()
base_name = os.path.join(self.mkdtemp(), 'archive')
- make_archive(base_name, 'gztar', root_dir, base_dir)
+ tarball = make_archive(base_name, 'gztar', root_dir, base_dir)
# check if the compressed tarball was created
- tarball = base_name + '.tar.gz'
+ self.assertEqual(tarball, base_name + '.tar.gz')
self.assertTrue(os.path.isfile(tarball))
# now create another tarball using `tar`
@@ -451,13 +450,14 @@
self.assertEqual(self._tarinfo(tarball), self._tarinfo(tarball2))
# trying an uncompressed one
- make_archive(base_name, 'tar', root_dir, base_dir)
- tarball = base_name + '.tar'
+ tarball = make_archive(base_name, 'tar', root_dir, base_dir)
+ self.assertEqual(tarball, base_name + '.tar')
self.assertTrue(os.path.isfile(tarball))
# now for a dry_run
- make_archive(base_name, 'tar', root_dir, base_dir, dry_run=True)
- tarball = base_name + '.tar'
+ tarball = make_archive(base_name, 'tar', root_dir, base_dir,
+ dry_run=True)
+ self.assertEqual(tarball, base_name + '.tar')
self.assertTrue(os.path.isfile(tarball))
@unittest.skipUnless(zlib, "Requires zlib")
--
Repository URL: https://hg.python.org/cpython
More information about the Python-checkins
mailing list