diff options
Diffstat (limited to 'Lib/distutils/tests/test_sdist.py')
| -rw-r--r-- | Lib/distutils/tests/test_sdist.py | 102 |
1 files changed, 11 insertions, 91 deletions
diff --git a/Lib/distutils/tests/test_sdist.py b/Lib/distutils/tests/test_sdist.py index 7e7d98d..e6359d6 100644 --- a/Lib/distutils/tests/test_sdist.py +++ b/Lib/distutils/tests/test_sdist.py @@ -6,21 +6,13 @@ import warnings import zipfile from os.path import join from textwrap import dedent -from test.test_support import captured_stdout, check_warnings, run_unittest +from test.support import captured_stdout, check_warnings, run_unittest -# zlib is not used here, but if it's not available -# the tests that use zipfile may fail try: import zlib + ZLIB_SUPPORT = True except ImportError: - zlib = None - -try: - import grp - import pwd - UID_GID_SUPPORT = True -except ImportError: - UID_GID_SUPPORT = False + ZLIB_SUPPORT = False from distutils.command.sdist import sdist, show_formats @@ -89,7 +81,7 @@ class SDistTestCase(PyPIRCCommandTestCase): cmd.dist_dir = 'dist' return dist, cmd - @unittest.skipUnless(zlib, "requires zlib") + @unittest.skipUnless(ZLIB_SUPPORT, 'Need zlib support to run') def test_prune_file_list(self): # this test creates a project with some VCS dirs and an NFS rename # file, then launches sdist to check they get pruned on all systems @@ -132,7 +124,7 @@ class SDistTestCase(PyPIRCCommandTestCase): # making sure everything has been pruned correctly self.assertEqual(len(content), 4) - @unittest.skipUnless(zlib, "requires zlib") + @unittest.skipUnless(ZLIB_SUPPORT, 'Need zlib support to run') def test_make_distribution(self): # check if tar and gzip are installed @@ -167,29 +159,7 @@ class SDistTestCase(PyPIRCCommandTestCase): result.sort() self.assertEqual(result, ['fake-1.0.tar', 'fake-1.0.tar.gz']) - @unittest.skipUnless(zlib, "requires zlib") - def test_unicode_metadata_tgz(self): - """ - Unicode name or version should not break building to tar.gz format. - Reference issue #11638. - """ - - # create the sdist command with unicode parameters - dist, cmd = self.get_cmd({'name': u'fake', 'version': u'1.0'}) - - # create the sdist as gztar and run the command - cmd.formats = ['gztar'] - cmd.ensure_finalized() - cmd.run() - - # The command should have created the .tar.gz file - dist_folder = join(self.tmp_dir, 'dist') - result = os.listdir(dist_folder) - self.assertEqual(result, ['fake-1.0.tar.gz']) - - os.remove(join(dist_folder, 'fake-1.0.tar.gz')) - - @unittest.skipUnless(zlib, "requires zlib") + @unittest.skipUnless(ZLIB_SUPPORT, 'Need zlib support to run') def test_add_defaults(self): # http://bugs.python.org/issue2279 @@ -262,7 +232,7 @@ class SDistTestCase(PyPIRCCommandTestCase): f.close() self.assertEqual(manifest, MANIFEST % {'sep': os.sep}) - @unittest.skipUnless(zlib, "requires zlib") + @unittest.skipUnless(ZLIB_SUPPORT, 'Need zlib support to run') def test_metadata_check_option(self): # testing the `medata-check` option dist, cmd = self.get_cmd(metadata={}) @@ -323,56 +293,6 @@ class SDistTestCase(PyPIRCCommandTestCase): cmd.formats = 'supazipa' self.assertRaises(DistutilsOptionError, cmd.finalize_options) - @unittest.skipUnless(zlib, "requires zlib") - @unittest.skipUnless(UID_GID_SUPPORT, "Requires grp and pwd support") - def test_make_distribution_owner_group(self): - - # check if tar and gzip are installed - if (find_executable('tar') is None or - find_executable('gzip') is None): - return - - # now building a sdist - dist, cmd = self.get_cmd() - - # creating a gztar and specifying the owner+group - cmd.formats = ['gztar'] - cmd.owner = pwd.getpwuid(0)[0] - cmd.group = grp.getgrgid(0)[0] - cmd.ensure_finalized() - cmd.run() - - # making sure we have the good rights - archive_name = join(self.tmp_dir, 'dist', 'fake-1.0.tar.gz') - archive = tarfile.open(archive_name) - try: - for member in archive.getmembers(): - self.assertEqual(member.uid, 0) - self.assertEqual(member.gid, 0) - finally: - archive.close() - - # building a sdist again - dist, cmd = self.get_cmd() - - # creating a gztar - cmd.formats = ['gztar'] - cmd.ensure_finalized() - cmd.run() - - # making sure we have the good rights - archive_name = join(self.tmp_dir, 'dist', 'fake-1.0.tar.gz') - archive = tarfile.open(archive_name) - - # note that we are not testing the group ownership here - # because, depending on the platforms and the container - # rights (see #7408) - try: - for member in archive.getmembers(): - self.assertEqual(member.uid, os.getuid()) - finally: - archive.close() - # the following tests make sure there is a nice error message instead # of a traceback when parsing an invalid manifest template @@ -399,7 +319,7 @@ class SDistTestCase(PyPIRCCommandTestCase): # this used to crash instead of raising a warning: #8286 self._check_template('include examples/') - @unittest.skipUnless(zlib, "requires zlib") + @unittest.skipUnless(ZLIB_SUPPORT, 'Need zlib support to run') def test_get_file_list(self): # make sure MANIFEST is recalculated dist, cmd = self.get_cmd() @@ -441,7 +361,7 @@ class SDistTestCase(PyPIRCCommandTestCase): self.assertEqual(len(manifest2), 6) self.assertIn('doc2.txt', manifest2[-1]) - @unittest.skipUnless(zlib, "requires zlib") + @unittest.skipUnless(ZLIB_SUPPORT, 'Need zlib support to run') def test_manifest_marker(self): # check that autogenerated MANIFESTs have a marker dist, cmd = self.get_cmd() @@ -458,7 +378,7 @@ class SDistTestCase(PyPIRCCommandTestCase): self.assertEqual(manifest[0], '# file GENERATED by distutils, do NOT edit') - @unittest.skipUnless(zlib, 'requires zlib') + @unittest.skipUnless(ZLIB_SUPPORT, "Need zlib support to run") def test_manifest_comments(self): # make sure comments don't cause exceptions or wrong includes contents = dedent("""\ @@ -475,7 +395,7 @@ class SDistTestCase(PyPIRCCommandTestCase): cmd.run() self.assertEqual(cmd.filelist.files, ['good.py']) - @unittest.skipUnless(zlib, "requires zlib") + @unittest.skipUnless(ZLIB_SUPPORT, 'Need zlib support to run') def test_manual_manifest(self): # check that a MANIFEST without a marker is left alone dist, cmd = self.get_cmd() |
