summaryrefslogtreecommitdiffstats
path: root/Lib/distutils/tests
diff options
context:
space:
mode:
authorTarek Ziadé <ziade.tarek@gmail.com>2009-05-17 12:12:02 (GMT)
committerTarek Ziadé <ziade.tarek@gmail.com>2009-05-17 12:12:02 (GMT)
commiteb5f27ec9c19e2b2a125be8a5635cc0b257a4c02 (patch)
treecacde8c1ca174b912c99928aed0e8cc8a8e1c5f5 /Lib/distutils/tests
parent3f076d8b3df3a1aa3228bbe993d4f37d577fcc2f (diff)
downloadcpython-eb5f27ec9c19e2b2a125be8a5635cc0b257a4c02.zip
cpython-eb5f27ec9c19e2b2a125be8a5635cc0b257a4c02.tar.gz
cpython-eb5f27ec9c19e2b2a125be8a5635cc0b257a4c02.tar.bz2
Merged revisions 72736 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk ........ r72736 | tarek.ziade | 2009-05-17 14:04:57 +0200 (Sun, 17 May 2009) | 1 line pep8-fied distutils.archive_util + added minimum test coverage ........
Diffstat (limited to 'Lib/distutils/tests')
-rw-r--r--Lib/distutils/tests/test_archive_util.py70
1 files changed, 70 insertions, 0 deletions
diff --git a/Lib/distutils/tests/test_archive_util.py b/Lib/distutils/tests/test_archive_util.py
new file mode 100644
index 0000000..f5fd9ea
--- /dev/null
+++ b/Lib/distutils/tests/test_archive_util.py
@@ -0,0 +1,70 @@
+"""Tests for distutils.archive_util."""
+__revision__ = "$Id:$"
+
+import unittest
+import os
+
+from distutils.archive_util import (check_archive_formats, make_tarball,
+ make_zipfile, make_archive)
+from distutils.spawn import find_executable
+from distutils.tests import support
+
+try:
+ import zipfile
+ ZIP_SUPPORT = True
+except ImportError:
+ ZIP_SUPPORT = find_executable('zip')
+
+class ArchiveUtilTestCase(support.TempdirManager,
+ unittest.TestCase):
+
+ @unittest.skipUnless(find_executable('tar'), 'Need the tar command to run')
+ def test_make_tarball(self):
+ # creating something to tar
+ tmpdir = self.mkdtemp()
+ self.write_file([tmpdir, 'file1'], 'xxx')
+ self.write_file([tmpdir, 'file2'], 'xxx')
+
+ tmpdir2 = self.mkdtemp()
+ base_name = os.path.join(tmpdir2, 'archive')
+ make_tarball(base_name, tmpdir)
+
+ # check if the compressed tarball was created
+ tarball = base_name + '.tar.gz'
+ self.assert_(os.path.exists(tarball))
+
+ # trying an uncompressed one
+ base_name = os.path.join(tmpdir2, 'archive')
+ make_tarball(base_name, tmpdir, compress=None)
+ tarball = base_name + '.tar'
+ self.assert_(os.path.exists(tarball))
+
+ @unittest.skipUnless(ZIP_SUPPORT, 'Need zip support to run')
+ def test_make_tarball(self):
+ # creating something to tar
+ tmpdir = self.mkdtemp()
+ self.write_file([tmpdir, 'file1'], 'xxx')
+ self.write_file([tmpdir, 'file2'], 'xxx')
+
+ tmpdir2 = self.mkdtemp()
+ base_name = os.path.join(tmpdir2, 'archive')
+ make_zipfile(base_name, tmpdir)
+
+ # check if the compressed tarball was created
+ tarball = base_name + '.zip'
+
+ def test_check_archive_formats(self):
+ self.assertEquals(check_archive_formats(['gztar', 'xxx', 'zip']),
+ 'xxx')
+ self.assertEquals(check_archive_formats(['gztar', 'zip']), None)
+
+ def test_make_archive(self):
+ tmpdir = self.mkdtemp()
+ base_name = os.path.join(tmpdir, 'archive')
+ self.assertRaises(ValueError, make_archive, base_name, 'xxx')
+
+def test_suite():
+ return unittest.makeSuite(ArchiveUtilTestCase)
+
+if __name__ == "__main__":
+ unittest.main(defaultTest="test_suite")