2009-01-03 20:04:49 -04:00
|
|
|
"""Tests for distutils.command.sdist."""
|
|
|
|
import os
|
|
|
|
import unittest
|
|
|
|
import shutil
|
|
|
|
import zipfile
|
2009-10-02 20:49:48 -03:00
|
|
|
import tarfile
|
2009-09-12 11:43:43 -03:00
|
|
|
|
|
|
|
# zlib is not used here, but if it's not available
|
|
|
|
# the tests that use zipfile may fail
|
|
|
|
try:
|
|
|
|
import zlib
|
|
|
|
except ImportError:
|
|
|
|
zlib = None
|
|
|
|
|
2009-10-02 20:49:48 -03:00
|
|
|
try:
|
|
|
|
import grp
|
|
|
|
import pwd
|
|
|
|
UID_GID_SUPPORT = True
|
|
|
|
except ImportError:
|
|
|
|
UID_GID_SUPPORT = False
|
|
|
|
|
2009-01-03 20:04:49 -04:00
|
|
|
from os.path import join
|
2009-01-25 19:34:00 -04:00
|
|
|
import sys
|
2009-02-14 10:10:23 -04:00
|
|
|
import tempfile
|
2009-05-16 13:37:06 -03:00
|
|
|
import warnings
|
2009-01-03 20:04:49 -04:00
|
|
|
|
Merged revisions 86236,86240,86332,86340,87271,87273,87447 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/branches/py3k
To comply with the 2.x doc style, the methods in trace.rst use brackets around
optional arguments. The rest is a mostly straight merge, modulo support changed
to test_support and use of the old super call style in test_tuple.
........
r86236 | eric.araujo | 2010-11-06 03:44:43 +0100 (sam., 06 nov. 2010) | 2 lines
Make sure each test can be run standalone (./python Lib/distutils/tests/x.py)
........
r86240 | eric.araujo | 2010-11-06 05:11:59 +0100 (sam., 06 nov. 2010) | 2 lines
Prevent ResourceWarnings in test_gettext
........
r86332 | eric.araujo | 2010-11-08 19:15:17 +0100 (lun., 08 nov. 2010) | 4 lines
Add missing NEWS entry for a fix committed by Senthil.
All recent modifications to distutils should now be covered in NEWS.
........
r86340 | eric.araujo | 2010-11-08 22:48:23 +0100 (lun., 08 nov. 2010) | 2 lines
This was actually fixed for the previous alpha.
........
r87271 | eric.araujo | 2010-12-15 20:09:58 +0100 (mer., 15 déc. 2010) | 2 lines
Improve trace documentation (#9264). Patch by Eli Bendersky.
........
r87273 | eric.araujo | 2010-12-15 20:30:15 +0100 (mer., 15 déc. 2010) | 2 lines
Use nested method directives, rewrap long lines, fix whitespace.
........
r87447 | eric.araujo | 2010-12-23 20:13:05 +0100 (jeu., 23 déc. 2010) | 2 lines
Fix typo in superclass method name
........
2011-02-02 20:12:18 -04:00
|
|
|
from test.test_support import captured_stdout, check_warnings, run_unittest
|
2009-05-14 09:40:59 -03:00
|
|
|
|
Merged revisions 86236,86240,86332,86340,87271,87273,87447 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/branches/py3k
To comply with the 2.x doc style, the methods in trace.rst use brackets around
optional arguments. The rest is a mostly straight merge, modulo support changed
to test_support and use of the old super call style in test_tuple.
........
r86236 | eric.araujo | 2010-11-06 03:44:43 +0100 (sam., 06 nov. 2010) | 2 lines
Make sure each test can be run standalone (./python Lib/distutils/tests/x.py)
........
r86240 | eric.araujo | 2010-11-06 05:11:59 +0100 (sam., 06 nov. 2010) | 2 lines
Prevent ResourceWarnings in test_gettext
........
r86332 | eric.araujo | 2010-11-08 19:15:17 +0100 (lun., 08 nov. 2010) | 4 lines
Add missing NEWS entry for a fix committed by Senthil.
All recent modifications to distutils should now be covered in NEWS.
........
r86340 | eric.araujo | 2010-11-08 22:48:23 +0100 (lun., 08 nov. 2010) | 2 lines
This was actually fixed for the previous alpha.
........
r87271 | eric.araujo | 2010-12-15 20:09:58 +0100 (mer., 15 déc. 2010) | 2 lines
Improve trace documentation (#9264). Patch by Eli Bendersky.
........
r87273 | eric.araujo | 2010-12-15 20:30:15 +0100 (mer., 15 déc. 2010) | 2 lines
Use nested method directives, rewrap long lines, fix whitespace.
........
r87447 | eric.araujo | 2010-12-23 20:13:05 +0100 (jeu., 23 déc. 2010) | 2 lines
Fix typo in superclass method name
........
2011-02-02 20:12:18 -04:00
|
|
|
from distutils.command.sdist import sdist, show_formats
|
2009-01-03 20:04:49 -04:00
|
|
|
from distutils.core import Distribution
|
|
|
|
from distutils.tests.test_config import PyPIRCCommandTestCase
|
2009-05-14 11:56:14 -03:00
|
|
|
from distutils.errors import DistutilsExecError, DistutilsOptionError
|
2009-01-29 19:49:17 -04:00
|
|
|
from distutils.spawn import find_executable
|
2009-02-16 17:38:01 -04:00
|
|
|
from distutils.tests import support
|
2009-05-16 13:37:06 -03:00
|
|
|
from distutils.log import WARN
|
2009-05-14 09:40:59 -03:00
|
|
|
from distutils.archive_util import ARCHIVE_FORMATS
|
2009-01-03 20:04:49 -04:00
|
|
|
|
|
|
|
SETUP_PY = """
|
|
|
|
from distutils.core import setup
|
|
|
|
import somecode
|
|
|
|
|
|
|
|
setup(name='fake')
|
|
|
|
"""
|
|
|
|
|
2009-02-16 17:38:01 -04:00
|
|
|
MANIFEST = """\
|
2010-08-14 00:07:46 -03:00
|
|
|
# file GENERATED by distutils, do NOT edit
|
2009-02-16 17:38:01 -04:00
|
|
|
README
|
2009-02-17 19:06:51 -04:00
|
|
|
inroot.txt
|
2009-02-16 17:38:01 -04:00
|
|
|
setup.py
|
2009-02-16 17:41:54 -04:00
|
|
|
data%(sep)sdata.dt
|
|
|
|
scripts%(sep)sscript.py
|
2009-02-17 05:42:44 -04:00
|
|
|
some%(sep)sfile.txt
|
|
|
|
some%(sep)sother_file.txt
|
2009-02-16 17:41:54 -04:00
|
|
|
somecode%(sep)s__init__.py
|
|
|
|
somecode%(sep)sdoc.dat
|
|
|
|
somecode%(sep)sdoc.txt
|
2009-01-03 20:04:49 -04:00
|
|
|
"""
|
|
|
|
|
2009-05-16 13:37:06 -03:00
|
|
|
class SDistTestCase(PyPIRCCommandTestCase):
|
2009-01-03 20:04:49 -04:00
|
|
|
|
|
|
|
def setUp(self):
|
2009-02-14 10:10:23 -04:00
|
|
|
# PyPIRCCommandTestCase creates a temp dir already
|
|
|
|
# and put it in self.tmp_dir
|
2009-05-16 13:37:06 -03:00
|
|
|
super(SDistTestCase, self).setUp()
|
2009-02-14 10:10:23 -04:00
|
|
|
# setting up an environment
|
2009-01-03 20:04:49 -04:00
|
|
|
self.old_path = os.getcwd()
|
2009-02-14 10:10:23 -04:00
|
|
|
os.mkdir(join(self.tmp_dir, 'somecode'))
|
|
|
|
os.mkdir(join(self.tmp_dir, 'dist'))
|
2009-02-16 17:38:01 -04:00
|
|
|
# a package, and a README
|
|
|
|
self.write_file((self.tmp_dir, 'README'), 'xxx')
|
|
|
|
self.write_file((self.tmp_dir, 'somecode', '__init__.py'), '#')
|
|
|
|
self.write_file((self.tmp_dir, 'setup.py'), SETUP_PY)
|
2009-02-14 10:10:23 -04:00
|
|
|
os.chdir(self.tmp_dir)
|
2009-01-03 20:04:49 -04:00
|
|
|
|
|
|
|
def tearDown(self):
|
2009-02-14 10:10:23 -04:00
|
|
|
# back to normal
|
2009-01-03 20:04:49 -04:00
|
|
|
os.chdir(self.old_path)
|
2009-05-16 13:37:06 -03:00
|
|
|
super(SDistTestCase, self).tearDown()
|
2009-02-16 17:38:01 -04:00
|
|
|
|
|
|
|
def get_cmd(self, metadata=None):
|
|
|
|
"""Returns a cmd"""
|
|
|
|
if metadata is None:
|
|
|
|
metadata = {'name': 'fake', 'version': '1.0',
|
|
|
|
'url': 'xxx', 'author': 'xxx',
|
|
|
|
'author_email': 'xxx'}
|
|
|
|
dist = Distribution(metadata)
|
|
|
|
dist.script_name = 'setup.py'
|
|
|
|
dist.packages = ['somecode']
|
|
|
|
dist.include_package_data = True
|
|
|
|
cmd = sdist(dist)
|
|
|
|
cmd.dist_dir = 'dist'
|
|
|
|
def _warn(*args):
|
|
|
|
pass
|
|
|
|
cmd.warn = _warn
|
|
|
|
return dist, cmd
|
2009-01-03 20:04:49 -04:00
|
|
|
|
2009-09-12 11:43:43 -03:00
|
|
|
@unittest.skipUnless(zlib, "requires zlib")
|
2009-01-03 20:04:49 -04:00
|
|
|
def test_prune_file_list(self):
|
|
|
|
# this test creates a package with some vcs dirs in it
|
|
|
|
# and launch sdist to make sure they get pruned
|
|
|
|
# on all systems
|
|
|
|
|
|
|
|
# creating VCS directories with some files in them
|
2009-02-14 10:10:23 -04:00
|
|
|
os.mkdir(join(self.tmp_dir, 'somecode', '.svn'))
|
2009-02-16 17:38:01 -04:00
|
|
|
self.write_file((self.tmp_dir, 'somecode', '.svn', 'ok.py'), 'xxx')
|
2009-01-03 20:04:49 -04:00
|
|
|
|
2009-02-14 10:10:23 -04:00
|
|
|
os.mkdir(join(self.tmp_dir, 'somecode', '.hg'))
|
2009-02-16 17:38:01 -04:00
|
|
|
self.write_file((self.tmp_dir, 'somecode', '.hg',
|
2009-01-03 20:04:49 -04:00
|
|
|
'ok'), 'xxx')
|
|
|
|
|
2009-02-14 10:10:23 -04:00
|
|
|
os.mkdir(join(self.tmp_dir, 'somecode', '.git'))
|
2009-02-16 17:38:01 -04:00
|
|
|
self.write_file((self.tmp_dir, 'somecode', '.git',
|
2009-01-03 20:04:49 -04:00
|
|
|
'ok'), 'xxx')
|
|
|
|
|
|
|
|
# now building a sdist
|
2009-02-16 17:38:01 -04:00
|
|
|
dist, cmd = self.get_cmd()
|
2009-01-03 20:04:49 -04:00
|
|
|
|
|
|
|
# zip is available universally
|
|
|
|
# (tar might not be installed under win32)
|
|
|
|
cmd.formats = ['zip']
|
2009-02-16 17:38:01 -04:00
|
|
|
|
|
|
|
cmd.ensure_finalized()
|
2009-01-03 20:04:49 -04:00
|
|
|
cmd.run()
|
|
|
|
|
|
|
|
# now let's check what we have
|
2009-02-14 10:10:23 -04:00
|
|
|
dist_folder = join(self.tmp_dir, 'dist')
|
2009-01-03 20:04:49 -04:00
|
|
|
files = os.listdir(dist_folder)
|
2010-11-21 09:34:58 -04:00
|
|
|
self.assertEqual(files, ['fake-1.0.zip'])
|
2009-01-03 20:04:49 -04:00
|
|
|
|
|
|
|
zip_file = zipfile.ZipFile(join(dist_folder, 'fake-1.0.zip'))
|
|
|
|
try:
|
|
|
|
content = zip_file.namelist()
|
|
|
|
finally:
|
|
|
|
zip_file.close()
|
|
|
|
|
|
|
|
# making sure everything has been pruned correctly
|
2010-11-21 09:34:58 -04:00
|
|
|
self.assertEqual(len(content), 4)
|
2009-01-03 20:04:49 -04:00
|
|
|
|
2009-09-12 11:43:43 -03:00
|
|
|
@unittest.skipUnless(zlib, "requires zlib")
|
2009-01-25 19:34:00 -04:00
|
|
|
def test_make_distribution(self):
|
|
|
|
|
2009-01-29 19:49:17 -04:00
|
|
|
# check if tar and gzip are installed
|
|
|
|
if (find_executable('tar') is None or
|
|
|
|
find_executable('gzip') is None):
|
|
|
|
return
|
2009-01-25 19:34:00 -04:00
|
|
|
|
|
|
|
# now building a sdist
|
2009-02-16 17:38:01 -04:00
|
|
|
dist, cmd = self.get_cmd()
|
2009-01-25 19:34:00 -04:00
|
|
|
|
|
|
|
# creating a gztar then a tar
|
|
|
|
cmd.formats = ['gztar', 'tar']
|
2009-02-16 17:38:01 -04:00
|
|
|
cmd.ensure_finalized()
|
2009-01-25 19:34:00 -04:00
|
|
|
cmd.run()
|
|
|
|
|
|
|
|
# making sure we have two files
|
2009-02-14 10:10:23 -04:00
|
|
|
dist_folder = join(self.tmp_dir, 'dist')
|
2009-01-25 19:34:00 -04:00
|
|
|
result = os.listdir(dist_folder)
|
|
|
|
result.sort()
|
2010-11-21 09:34:58 -04:00
|
|
|
self.assertEqual(result, ['fake-1.0.tar', 'fake-1.0.tar.gz'] )
|
2009-01-25 19:34:00 -04:00
|
|
|
|
|
|
|
os.remove(join(dist_folder, 'fake-1.0.tar'))
|
|
|
|
os.remove(join(dist_folder, 'fake-1.0.tar.gz'))
|
|
|
|
|
|
|
|
# now trying a tar then a gztar
|
|
|
|
cmd.formats = ['tar', 'gztar']
|
2009-02-16 17:38:01 -04:00
|
|
|
|
|
|
|
cmd.ensure_finalized()
|
2009-01-25 19:34:00 -04:00
|
|
|
cmd.run()
|
|
|
|
|
|
|
|
result = os.listdir(dist_folder)
|
|
|
|
result.sort()
|
2010-11-21 09:34:58 -04:00
|
|
|
self.assertEqual(result, ['fake-1.0.tar', 'fake-1.0.tar.gz'])
|
2009-01-25 19:34:00 -04:00
|
|
|
|
2009-09-12 11:43:43 -03:00
|
|
|
@unittest.skipUnless(zlib, "requires zlib")
|
2009-02-16 17:38:01 -04:00
|
|
|
def test_add_defaults(self):
|
|
|
|
|
|
|
|
# http://bugs.python.org/issue2279
|
|
|
|
|
|
|
|
# add_default should also include
|
|
|
|
# data_files and package_data
|
|
|
|
dist, cmd = self.get_cmd()
|
|
|
|
|
|
|
|
# filling data_files by pointing files
|
|
|
|
# in package_data
|
|
|
|
dist.package_data = {'': ['*.cfg', '*.dat'],
|
|
|
|
'somecode': ['*.txt']}
|
|
|
|
self.write_file((self.tmp_dir, 'somecode', 'doc.txt'), '#')
|
|
|
|
self.write_file((self.tmp_dir, 'somecode', 'doc.dat'), '#')
|
|
|
|
|
|
|
|
# adding some data in data_files
|
|
|
|
data_dir = join(self.tmp_dir, 'data')
|
|
|
|
os.mkdir(data_dir)
|
|
|
|
self.write_file((data_dir, 'data.dt'), '#')
|
2009-02-17 05:42:44 -04:00
|
|
|
some_dir = join(self.tmp_dir, 'some')
|
|
|
|
os.mkdir(some_dir)
|
2009-02-17 19:06:51 -04:00
|
|
|
self.write_file((self.tmp_dir, 'inroot.txt'), '#')
|
2009-02-17 05:42:44 -04:00
|
|
|
self.write_file((some_dir, 'file.txt'), '#')
|
|
|
|
self.write_file((some_dir, 'other_file.txt'), '#')
|
|
|
|
|
2009-02-17 19:06:51 -04:00
|
|
|
dist.data_files = [('data', ['data/data.dt',
|
|
|
|
'inroot.txt',
|
|
|
|
'notexisting']),
|
2009-02-17 05:42:44 -04:00
|
|
|
'some/file.txt',
|
|
|
|
'some/other_file.txt']
|
2009-02-16 17:38:01 -04:00
|
|
|
|
|
|
|
# adding a script
|
|
|
|
script_dir = join(self.tmp_dir, 'scripts')
|
|
|
|
os.mkdir(script_dir)
|
|
|
|
self.write_file((script_dir, 'script.py'), '#')
|
|
|
|
dist.scripts = [join('scripts', 'script.py')]
|
|
|
|
|
|
|
|
cmd.formats = ['zip']
|
|
|
|
cmd.use_defaults = True
|
|
|
|
|
|
|
|
cmd.ensure_finalized()
|
|
|
|
cmd.run()
|
|
|
|
|
|
|
|
# now let's check what we have
|
|
|
|
dist_folder = join(self.tmp_dir, 'dist')
|
|
|
|
files = os.listdir(dist_folder)
|
2010-11-21 09:34:58 -04:00
|
|
|
self.assertEqual(files, ['fake-1.0.zip'])
|
2009-02-16 17:38:01 -04:00
|
|
|
|
|
|
|
zip_file = zipfile.ZipFile(join(dist_folder, 'fake-1.0.zip'))
|
|
|
|
try:
|
|
|
|
content = zip_file.namelist()
|
|
|
|
finally:
|
|
|
|
zip_file.close()
|
|
|
|
|
|
|
|
# making sure everything was added
|
2010-11-21 09:34:58 -04:00
|
|
|
self.assertEqual(len(content), 11)
|
2009-02-16 17:38:01 -04:00
|
|
|
|
|
|
|
# checking the MANIFEST
|
2010-11-06 01:06:18 -03:00
|
|
|
f = open(join(self.tmp_dir, 'MANIFEST'))
|
|
|
|
try:
|
|
|
|
manifest = f.read()
|
2010-11-21 09:34:58 -04:00
|
|
|
self.assertEqual(manifest, MANIFEST % {'sep': os.sep})
|
2010-11-06 01:06:18 -03:00
|
|
|
finally:
|
|
|
|
f.close()
|
2009-02-16 17:38:01 -04:00
|
|
|
|
2009-09-12 11:43:43 -03:00
|
|
|
@unittest.skipUnless(zlib, "requires zlib")
|
2009-05-16 13:37:06 -03:00
|
|
|
def test_metadata_check_option(self):
|
|
|
|
# testing the `medata-check` option
|
|
|
|
dist, cmd = self.get_cmd(metadata={})
|
|
|
|
|
|
|
|
# this should raise some warnings !
|
|
|
|
# with the `check` subcommand
|
|
|
|
cmd.ensure_finalized()
|
|
|
|
cmd.run()
|
|
|
|
warnings = self.get_logs(WARN)
|
2010-11-21 09:34:58 -04:00
|
|
|
self.assertEqual(len(warnings), 2)
|
2009-05-16 13:37:06 -03:00
|
|
|
|
|
|
|
# trying with a complete set of metadata
|
|
|
|
self.clear_logs()
|
|
|
|
dist, cmd = self.get_cmd()
|
|
|
|
cmd.ensure_finalized()
|
|
|
|
cmd.metadata_check = 0
|
|
|
|
cmd.run()
|
|
|
|
warnings = self.get_logs(WARN)
|
2010-11-21 09:34:58 -04:00
|
|
|
self.assertEqual(len(warnings), 0)
|
2009-05-16 13:37:06 -03:00
|
|
|
|
|
|
|
def test_check_metadata_deprecated(self):
|
|
|
|
# makes sure make_metadata is deprecated
|
|
|
|
dist, cmd = self.get_cmd()
|
|
|
|
with check_warnings() as w:
|
|
|
|
warnings.simplefilter("always")
|
|
|
|
cmd.check_metadata()
|
2010-11-21 09:34:58 -04:00
|
|
|
self.assertEqual(len(w.warnings), 1)
|
2009-05-16 13:37:06 -03:00
|
|
|
|
2009-05-14 09:40:59 -03:00
|
|
|
def test_show_formats(self):
|
|
|
|
with captured_stdout() as stdout:
|
|
|
|
show_formats()
|
|
|
|
|
|
|
|
# the output should be a header line + one line per format
|
|
|
|
num_formats = len(ARCHIVE_FORMATS.keys())
|
|
|
|
output = [line for line in stdout.getvalue().split('\n')
|
|
|
|
if line.strip().startswith('--formats=')]
|
2010-11-21 09:34:58 -04:00
|
|
|
self.assertEqual(len(output), num_formats)
|
2009-05-14 09:40:59 -03:00
|
|
|
|
2009-05-14 11:56:14 -03:00
|
|
|
def test_finalize_options(self):
|
|
|
|
|
|
|
|
dist, cmd = self.get_cmd()
|
|
|
|
cmd.finalize_options()
|
|
|
|
|
|
|
|
# default options set by finalize
|
2010-11-21 09:34:58 -04:00
|
|
|
self.assertEqual(cmd.manifest, 'MANIFEST')
|
|
|
|
self.assertEqual(cmd.template, 'MANIFEST.in')
|
|
|
|
self.assertEqual(cmd.dist_dir, 'dist')
|
2009-05-14 11:56:14 -03:00
|
|
|
|
|
|
|
# formats has to be a string splitable on (' ', ',') or
|
|
|
|
# a stringlist
|
|
|
|
cmd.formats = 1
|
|
|
|
self.assertRaises(DistutilsOptionError, cmd.finalize_options)
|
|
|
|
cmd.formats = ['zip']
|
|
|
|
cmd.finalize_options()
|
|
|
|
|
|
|
|
# formats has to be known
|
|
|
|
cmd.formats = 'supazipa'
|
|
|
|
self.assertRaises(DistutilsOptionError, cmd.finalize_options)
|
|
|
|
|
2009-10-02 20:49:48 -03:00
|
|
|
@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():
|
2010-11-21 09:34:58 -04:00
|
|
|
self.assertEqual(member.uid, 0)
|
|
|
|
self.assertEqual(member.gid, 0)
|
2009-10-02 20:49:48 -03:00
|
|
|
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)
|
2009-11-29 18:20:30 -04:00
|
|
|
|
|
|
|
# note that we are not testing the group ownership here
|
|
|
|
# because, depending on the platforms and the container
|
|
|
|
# rights (see #7408)
|
2009-10-02 20:49:48 -03:00
|
|
|
try:
|
|
|
|
for member in archive.getmembers():
|
2010-11-21 09:34:58 -04:00
|
|
|
self.assertEqual(member.uid, os.getuid())
|
2009-10-02 20:49:48 -03:00
|
|
|
finally:
|
|
|
|
archive.close()
|
2009-05-14 11:56:14 -03:00
|
|
|
|
2010-07-12 16:52:15 -03:00
|
|
|
@unittest.skipUnless(zlib, "requires zlib")
|
2010-05-17 07:06:20 -03:00
|
|
|
def test_get_file_list(self):
|
|
|
|
# make sure MANIFEST is recalculated
|
|
|
|
dist, cmd = self.get_cmd()
|
|
|
|
|
|
|
|
# filling data_files by pointing files in package_data
|
|
|
|
dist.package_data = {'somecode': ['*.txt']}
|
|
|
|
self.write_file((self.tmp_dir, 'somecode', 'doc.txt'), '#')
|
|
|
|
cmd.ensure_finalized()
|
|
|
|
cmd.run()
|
|
|
|
|
|
|
|
f = open(cmd.manifest)
|
|
|
|
try:
|
|
|
|
manifest = [line.strip() for line in f.read().split('\n')
|
|
|
|
if line.strip() != '']
|
|
|
|
finally:
|
|
|
|
f.close()
|
|
|
|
|
2010-11-21 09:34:58 -04:00
|
|
|
self.assertEqual(len(manifest), 5)
|
2010-05-17 07:06:20 -03:00
|
|
|
|
|
|
|
# adding a file
|
|
|
|
self.write_file((self.tmp_dir, 'somecode', 'doc2.txt'), '#')
|
|
|
|
|
|
|
|
# make sure build_py is reinitinialized, like a fresh run
|
|
|
|
build_py = dist.get_command_obj('build_py')
|
|
|
|
build_py.finalized = False
|
|
|
|
build_py.ensure_finalized()
|
|
|
|
|
|
|
|
cmd.run()
|
|
|
|
|
|
|
|
f = open(cmd.manifest)
|
|
|
|
try:
|
|
|
|
manifest2 = [line.strip() for line in f.read().split('\n')
|
|
|
|
if line.strip() != '']
|
|
|
|
finally:
|
|
|
|
f.close()
|
|
|
|
|
|
|
|
# do we have the new file in MANIFEST ?
|
2010-11-21 09:34:58 -04:00
|
|
|
self.assertEqual(len(manifest2), 6)
|
2010-05-17 07:06:20 -03:00
|
|
|
self.assertIn('doc2.txt', manifest2[-1])
|
|
|
|
|
2010-08-14 00:07:46 -03:00
|
|
|
def test_manifest_marker(self):
|
|
|
|
# check that autogenerated MANIFESTs have a marker
|
|
|
|
dist, cmd = self.get_cmd()
|
|
|
|
cmd.ensure_finalized()
|
|
|
|
cmd.run()
|
|
|
|
|
|
|
|
f = open(cmd.manifest)
|
|
|
|
try:
|
|
|
|
manifest = [line.strip() for line in f.read().split('\n')
|
|
|
|
if line.strip() != '']
|
|
|
|
finally:
|
|
|
|
f.close()
|
|
|
|
|
|
|
|
self.assertEqual(manifest[0],
|
|
|
|
'# file GENERATED by distutils, do NOT edit')
|
|
|
|
|
|
|
|
def test_manual_manifest(self):
|
|
|
|
# check that a MANIFEST without a marker is left alone
|
|
|
|
dist, cmd = self.get_cmd()
|
|
|
|
cmd.ensure_finalized()
|
|
|
|
self.write_file((self.tmp_dir, cmd.manifest), 'README.manual')
|
|
|
|
cmd.run()
|
|
|
|
|
|
|
|
f = open(cmd.manifest)
|
|
|
|
try:
|
|
|
|
manifest = [line.strip() for line in f.read().split('\n')
|
|
|
|
if line.strip() != '']
|
|
|
|
finally:
|
|
|
|
f.close()
|
|
|
|
|
|
|
|
self.assertEqual(manifest, ['README.manual'])
|
2010-05-17 07:06:20 -03:00
|
|
|
|
2009-01-03 20:04:49 -04:00
|
|
|
def test_suite():
|
2009-05-16 13:37:06 -03:00
|
|
|
return unittest.makeSuite(SDistTestCase)
|
2009-01-03 20:04:49 -04:00
|
|
|
|
|
|
|
if __name__ == "__main__":
|
Merged revisions 86236,86240,86332,86340,87271,87273,87447 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/branches/py3k
To comply with the 2.x doc style, the methods in trace.rst use brackets around
optional arguments. The rest is a mostly straight merge, modulo support changed
to test_support and use of the old super call style in test_tuple.
........
r86236 | eric.araujo | 2010-11-06 03:44:43 +0100 (sam., 06 nov. 2010) | 2 lines
Make sure each test can be run standalone (./python Lib/distutils/tests/x.py)
........
r86240 | eric.araujo | 2010-11-06 05:11:59 +0100 (sam., 06 nov. 2010) | 2 lines
Prevent ResourceWarnings in test_gettext
........
r86332 | eric.araujo | 2010-11-08 19:15:17 +0100 (lun., 08 nov. 2010) | 4 lines
Add missing NEWS entry for a fix committed by Senthil.
All recent modifications to distutils should now be covered in NEWS.
........
r86340 | eric.araujo | 2010-11-08 22:48:23 +0100 (lun., 08 nov. 2010) | 2 lines
This was actually fixed for the previous alpha.
........
r87271 | eric.araujo | 2010-12-15 20:09:58 +0100 (mer., 15 déc. 2010) | 2 lines
Improve trace documentation (#9264). Patch by Eli Bendersky.
........
r87273 | eric.araujo | 2010-12-15 20:30:15 +0100 (mer., 15 déc. 2010) | 2 lines
Use nested method directives, rewrap long lines, fix whitespace.
........
r87447 | eric.araujo | 2010-12-23 20:13:05 +0100 (jeu., 23 déc. 2010) | 2 lines
Fix typo in superclass method name
........
2011-02-02 20:12:18 -04:00
|
|
|
run_unittest(test_suite())
|