2009-01-09 00:11:44 -04:00
|
|
|
"""Tests for distutils.command.sdist."""
|
|
|
|
import os
|
2011-07-30 23:06:12 -03:00
|
|
|
import tarfile
|
2009-01-09 00:11:44 -04:00
|
|
|
import unittest
|
2011-07-30 23:06:12 -03:00
|
|
|
import warnings
|
2009-01-09 00:11:44 -04:00
|
|
|
import zipfile
|
|
|
|
from os.path import join
|
2011-07-30 23:06:12 -03:00
|
|
|
from textwrap import dedent
|
2012-02-25 21:14:33 -04:00
|
|
|
from test.support import captured_stdout, check_warnings, run_unittest
|
2009-01-09 00:11:44 -04:00
|
|
|
|
2012-02-25 11:28:05 -04:00
|
|
|
try:
|
|
|
|
import zlib
|
|
|
|
ZLIB_SUPPORT = True
|
|
|
|
except ImportError:
|
|
|
|
ZLIB_SUPPORT = False
|
|
|
|
|
2009-05-14 09:45:48 -03:00
|
|
|
|
Merged revisions 86236,86240,86332,86340,87271,87273,87447 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/branches/py3k
The missing NEWS entries correspond to changes that were made before 3.1.3, but
I think it’s not usual to edit entries of released versions, so I put them at
the top.
........
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 17:38:37 -04:00
|
|
|
from distutils.command.sdist import sdist, show_formats
|
2009-01-09 00:11:44 -04:00
|
|
|
from distutils.core import Distribution
|
|
|
|
from distutils.tests.test_config import PyPIRCCommandTestCase
|
2011-07-30 23:06:12 -03:00
|
|
|
from distutils.errors import DistutilsOptionError
|
2009-01-29 19:54:06 -04:00
|
|
|
from distutils.spawn import find_executable
|
2009-05-16 13:52:13 -03:00
|
|
|
from distutils.log import WARN
|
2011-09-02 19:42:04 -03:00
|
|
|
from distutils.filelist import FileList
|
2009-05-14 09:45:48 -03:00
|
|
|
from distutils.archive_util import ARCHIVE_FORMATS
|
2009-01-09 00:11:44 -04:00
|
|
|
|
|
|
|
SETUP_PY = """
|
|
|
|
from distutils.core import setup
|
|
|
|
import somecode
|
|
|
|
|
|
|
|
setup(name='fake')
|
|
|
|
"""
|
|
|
|
|
2009-02-16 17:49:12 -04:00
|
|
|
MANIFEST = """\
|
2010-08-13 23:36:26 -03:00
|
|
|
# file GENERATED by distutils, do NOT edit
|
2009-02-16 17:49:12 -04:00
|
|
|
README
|
2012-02-25 11:28:05 -04:00
|
|
|
buildout.cfg
|
2009-02-17 19:10:18 -04:00
|
|
|
inroot.txt
|
2009-02-16 17:49:12 -04:00
|
|
|
setup.py
|
2009-02-16 17:51:13 -04:00
|
|
|
data%(sep)sdata.dt
|
|
|
|
scripts%(sep)sscript.py
|
2009-02-17 05:47:25 -04:00
|
|
|
some%(sep)sfile.txt
|
|
|
|
some%(sep)sother_file.txt
|
2009-02-16 17:51:13 -04:00
|
|
|
somecode%(sep)s__init__.py
|
|
|
|
somecode%(sep)sdoc.dat
|
|
|
|
somecode%(sep)sdoc.txt
|
2009-01-09 00:11:44 -04:00
|
|
|
"""
|
|
|
|
|
2009-05-16 13:52:13 -03:00
|
|
|
class SDistTestCase(PyPIRCCommandTestCase):
|
2009-01-09 00:11:44 -04:00
|
|
|
|
|
|
|
def setUp(self):
|
2009-02-14 10:35:51 -04:00
|
|
|
# PyPIRCCommandTestCase creates a temp dir already
|
|
|
|
# and put it in self.tmp_dir
|
2009-05-16 13:52:13 -03:00
|
|
|
super(SDistTestCase, self).setUp()
|
2009-02-14 10:35:51 -04:00
|
|
|
# setting up an environment
|
2009-01-09 00:11:44 -04:00
|
|
|
self.old_path = os.getcwd()
|
2009-02-14 10:35:51 -04:00
|
|
|
os.mkdir(join(self.tmp_dir, 'somecode'))
|
|
|
|
os.mkdir(join(self.tmp_dir, 'dist'))
|
2009-02-16 17:49:12 -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:35:51 -04:00
|
|
|
os.chdir(self.tmp_dir)
|
2009-01-09 00:11:44 -04:00
|
|
|
|
|
|
|
def tearDown(self):
|
2009-02-14 10:35:51 -04:00
|
|
|
# back to normal
|
2009-01-09 00:11:44 -04:00
|
|
|
os.chdir(self.old_path)
|
2009-05-16 13:52:13 -03:00
|
|
|
super(SDistTestCase, self).tearDown()
|
2009-02-16 17:49:12 -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'
|
|
|
|
return dist, cmd
|
2009-01-09 00:11:44 -04:00
|
|
|
|
2011-03-15 17:02:59 -03:00
|
|
|
@unittest.skipUnless(ZLIB_SUPPORT, 'Need zlib support to run')
|
2009-01-09 00:11:44 -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:35:51 -04:00
|
|
|
os.mkdir(join(self.tmp_dir, 'somecode', '.svn'))
|
2009-02-16 17:49:12 -04:00
|
|
|
self.write_file((self.tmp_dir, 'somecode', '.svn', 'ok.py'), 'xxx')
|
2009-01-09 00:11:44 -04:00
|
|
|
|
2009-02-14 10:35:51 -04:00
|
|
|
os.mkdir(join(self.tmp_dir, 'somecode', '.hg'))
|
2009-02-16 17:49:12 -04:00
|
|
|
self.write_file((self.tmp_dir, 'somecode', '.hg',
|
2009-01-09 00:11:44 -04:00
|
|
|
'ok'), 'xxx')
|
|
|
|
|
2009-02-14 10:35:51 -04:00
|
|
|
os.mkdir(join(self.tmp_dir, 'somecode', '.git'))
|
2009-02-16 17:49:12 -04:00
|
|
|
self.write_file((self.tmp_dir, 'somecode', '.git',
|
2009-01-09 00:11:44 -04:00
|
|
|
'ok'), 'xxx')
|
|
|
|
|
|
|
|
# now building a sdist
|
2009-02-16 17:49:12 -04:00
|
|
|
dist, cmd = self.get_cmd()
|
2009-01-09 00:11:44 -04:00
|
|
|
|
|
|
|
# zip is available universally
|
|
|
|
# (tar might not be installed under win32)
|
|
|
|
cmd.formats = ['zip']
|
2009-02-16 17:49:12 -04:00
|
|
|
|
|
|
|
cmd.ensure_finalized()
|
2009-01-09 00:11:44 -04:00
|
|
|
cmd.run()
|
|
|
|
|
|
|
|
# now let's check what we have
|
2009-02-14 10:35:51 -04:00
|
|
|
dist_folder = join(self.tmp_dir, 'dist')
|
2009-01-09 00:11:44 -04:00
|
|
|
files = os.listdir(dist_folder)
|
2010-11-20 21:30:29 -04:00
|
|
|
self.assertEqual(files, ['fake-1.0.zip'])
|
2009-01-09 00:11:44 -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-20 21:30:29 -04:00
|
|
|
self.assertEqual(len(content), 4)
|
2009-01-09 00:11:44 -04:00
|
|
|
|
2011-03-15 17:02:59 -03:00
|
|
|
@unittest.skipUnless(ZLIB_SUPPORT, 'Need zlib support to run')
|
2009-01-26 13:23:20 -04:00
|
|
|
def test_make_distribution(self):
|
|
|
|
|
2009-01-29 19:54:06 -04:00
|
|
|
# check if tar and gzip are installed
|
|
|
|
if (find_executable('tar') is None or
|
|
|
|
find_executable('gzip') is None):
|
|
|
|
return
|
2009-01-26 13:23:20 -04:00
|
|
|
|
|
|
|
# now building a sdist
|
2009-02-16 17:49:12 -04:00
|
|
|
dist, cmd = self.get_cmd()
|
2009-01-26 13:23:20 -04:00
|
|
|
|
|
|
|
# creating a gztar then a tar
|
|
|
|
cmd.formats = ['gztar', 'tar']
|
2009-02-16 17:49:12 -04:00
|
|
|
cmd.ensure_finalized()
|
2009-01-26 13:23:20 -04:00
|
|
|
cmd.run()
|
|
|
|
|
|
|
|
# making sure we have two files
|
2009-02-14 10:35:51 -04:00
|
|
|
dist_folder = join(self.tmp_dir, 'dist')
|
2009-01-26 13:23:20 -04:00
|
|
|
result = os.listdir(dist_folder)
|
|
|
|
result.sort()
|
2012-02-25 11:28:05 -04:00
|
|
|
self.assertEqual(result, ['fake-1.0.tar', 'fake-1.0.tar.gz'])
|
2009-01-26 13:23:20 -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:49:12 -04:00
|
|
|
|
|
|
|
cmd.ensure_finalized()
|
2009-01-26 13:23:20 -04:00
|
|
|
cmd.run()
|
|
|
|
|
|
|
|
result = os.listdir(dist_folder)
|
|
|
|
result.sort()
|
2010-11-20 21:30:29 -04:00
|
|
|
self.assertEqual(result, ['fake-1.0.tar', 'fake-1.0.tar.gz'])
|
2009-01-26 13:23:20 -04:00
|
|
|
|
2011-03-15 17:02:59 -03:00
|
|
|
@unittest.skipUnless(ZLIB_SUPPORT, 'Need zlib support to run')
|
2009-02-16 17:49:12 -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:47:25 -04:00
|
|
|
some_dir = join(self.tmp_dir, 'some')
|
|
|
|
os.mkdir(some_dir)
|
2012-02-25 11:28:05 -04:00
|
|
|
# make sure VCS directories are pruned (#14004)
|
|
|
|
hg_dir = join(self.tmp_dir, '.hg')
|
|
|
|
os.mkdir(hg_dir)
|
|
|
|
self.write_file((hg_dir, 'last-message.txt'), '#')
|
|
|
|
# a buggy regex used to prevent this from working on windows (#6884)
|
|
|
|
self.write_file((self.tmp_dir, 'buildout.cfg'), '#')
|
2009-02-17 19:10:18 -04:00
|
|
|
self.write_file((self.tmp_dir, 'inroot.txt'), '#')
|
2009-02-17 05:47:25 -04:00
|
|
|
self.write_file((some_dir, 'file.txt'), '#')
|
|
|
|
self.write_file((some_dir, 'other_file.txt'), '#')
|
|
|
|
|
2009-02-17 19:10:18 -04:00
|
|
|
dist.data_files = [('data', ['data/data.dt',
|
2012-02-25 11:28:05 -04:00
|
|
|
'buildout.cfg',
|
2009-02-17 19:10:18 -04:00
|
|
|
'inroot.txt',
|
|
|
|
'notexisting']),
|
2009-02-17 05:47:25 -04:00
|
|
|
'some/file.txt',
|
|
|
|
'some/other_file.txt']
|
2009-02-16 17:49:12 -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-20 21:30:29 -04:00
|
|
|
self.assertEqual(files, ['fake-1.0.zip'])
|
2009-02-16 17:49:12 -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
|
2012-02-25 11:28:05 -04:00
|
|
|
self.assertEqual(len(content), 12)
|
2009-02-16 17:49:12 -04:00
|
|
|
|
|
|
|
# checking the MANIFEST
|
2010-11-05 23:58:56 -03:00
|
|
|
f = open(join(self.tmp_dir, 'MANIFEST'))
|
|
|
|
try:
|
|
|
|
manifest = f.read()
|
|
|
|
finally:
|
|
|
|
f.close()
|
2012-02-25 11:28:05 -04:00
|
|
|
self.assertEqual(manifest, MANIFEST % {'sep': os.sep})
|
2009-02-16 17:49:12 -04:00
|
|
|
|
2011-03-15 17:02:59 -03:00
|
|
|
@unittest.skipUnless(ZLIB_SUPPORT, 'Need zlib support to run')
|
2009-05-16 13:52:13 -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()
|
2011-09-02 19:28:43 -03:00
|
|
|
warnings = [msg for msg in self.get_logs(WARN) if
|
|
|
|
msg.startswith('warning: check:')]
|
2010-11-20 21:30:29 -04:00
|
|
|
self.assertEqual(len(warnings), 2)
|
2009-05-16 13:52:13 -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()
|
2011-09-02 19:28:43 -03:00
|
|
|
warnings = [msg for msg in self.get_logs(WARN) if
|
|
|
|
msg.startswith('warning: check:')]
|
2010-11-20 21:30:29 -04:00
|
|
|
self.assertEqual(len(warnings), 0)
|
2009-05-16 13:52:13 -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-20 21:30:29 -04:00
|
|
|
self.assertEqual(len(w.warnings), 1)
|
2009-05-16 13:52:13 -03:00
|
|
|
|
2009-05-14 09:45:48 -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-20 21:30:29 -04:00
|
|
|
self.assertEqual(len(output), num_formats)
|
2009-05-14 09:45:48 -03:00
|
|
|
|
2009-05-14 12:21:26 -03:00
|
|
|
def test_finalize_options(self):
|
|
|
|
dist, cmd = self.get_cmd()
|
|
|
|
cmd.finalize_options()
|
|
|
|
|
|
|
|
# default options set by finalize
|
2010-11-20 21:30:29 -04:00
|
|
|
self.assertEqual(cmd.manifest, 'MANIFEST')
|
|
|
|
self.assertEqual(cmd.template, 'MANIFEST.in')
|
|
|
|
self.assertEqual(cmd.dist_dir, 'dist')
|
2009-05-14 12:21:26 -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)
|
|
|
|
|
2011-09-02 19:42:04 -03:00
|
|
|
# the following tests make sure there is a nice error message instead
|
|
|
|
# of a traceback when parsing an invalid manifest template
|
|
|
|
|
2011-11-02 14:05:41 -03:00
|
|
|
def _check_template(self, content):
|
2011-09-02 19:42:04 -03:00
|
|
|
dist, cmd = self.get_cmd()
|
|
|
|
os.chdir(self.tmp_dir)
|
|
|
|
self.write_file('MANIFEST.in', content)
|
|
|
|
cmd.ensure_finalized()
|
|
|
|
cmd.filelist = FileList()
|
|
|
|
cmd.read_template()
|
|
|
|
warnings = self.get_logs(WARN)
|
|
|
|
self.assertEqual(len(warnings), 1)
|
|
|
|
|
|
|
|
def test_invalid_template_unknown_command(self):
|
2011-11-02 14:05:41 -03:00
|
|
|
self._check_template('taunt knights *')
|
2011-09-02 19:42:04 -03:00
|
|
|
|
|
|
|
def test_invalid_template_wrong_arguments(self):
|
|
|
|
# this manifest command takes one argument
|
2011-11-02 14:05:41 -03:00
|
|
|
self._check_template('prune')
|
2011-09-02 19:42:04 -03:00
|
|
|
|
|
|
|
@unittest.skipIf(os.name != 'nt', 'test relevant for Windows only')
|
|
|
|
def test_invalid_template_wrong_path(self):
|
|
|
|
# on Windows, trailing slashes are not allowed
|
|
|
|
# this used to crash instead of raising a warning: #8286
|
2011-11-02 14:05:41 -03:00
|
|
|
self._check_template('include examples/')
|
2011-09-02 19:42:04 -03:00
|
|
|
|
2011-03-15 17:02:59 -03:00
|
|
|
@unittest.skipUnless(ZLIB_SUPPORT, 'Need zlib support to run')
|
2010-05-17 07:48:29 -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'), '#')
|
2012-02-25 21:14:33 -04:00
|
|
|
cmd.formats = ['gztar']
|
2010-05-17 07:48:29 -03:00
|
|
|
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-20 21:30:29 -04:00
|
|
|
self.assertEqual(len(manifest), 5)
|
2010-05-17 07:48:29 -03:00
|
|
|
|
|
|
|
# adding a file
|
|
|
|
self.write_file((self.tmp_dir, 'somecode', 'doc2.txt'), '#')
|
|
|
|
|
2011-03-16 06:05:33 -03:00
|
|
|
# make sure build_py is reinitialized, like a fresh run
|
2010-05-17 07:48:29 -03:00
|
|
|
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-20 21:30:29 -04:00
|
|
|
self.assertEqual(len(manifest2), 6)
|
2010-05-17 07:48:29 -03:00
|
|
|
self.assertIn('doc2.txt', manifest2[-1])
|
|
|
|
|
2011-03-15 17:02:59 -03:00
|
|
|
@unittest.skipUnless(ZLIB_SUPPORT, 'Need zlib support to run')
|
2010-08-13 23:36:26 -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')
|
|
|
|
|
2011-07-30 23:06:12 -03:00
|
|
|
@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("""\
|
|
|
|
# bad.py
|
|
|
|
#bad.py
|
|
|
|
good.py
|
|
|
|
""")
|
|
|
|
dist, cmd = self.get_cmd()
|
|
|
|
cmd.ensure_finalized()
|
|
|
|
self.write_file((self.tmp_dir, cmd.manifest), contents)
|
|
|
|
self.write_file((self.tmp_dir, 'good.py'), '# pick me!')
|
|
|
|
self.write_file((self.tmp_dir, 'bad.py'), "# don't pick me!")
|
|
|
|
self.write_file((self.tmp_dir, '#bad.py'), "# don't pick me!")
|
|
|
|
cmd.run()
|
|
|
|
self.assertEqual(cmd.filelist.files, ['good.py'])
|
|
|
|
|
2011-03-15 17:02:59 -03:00
|
|
|
@unittest.skipUnless(ZLIB_SUPPORT, 'Need zlib support to run')
|
2010-08-13 23:36:26 -03:00
|
|
|
def test_manual_manifest(self):
|
|
|
|
# check that a MANIFEST without a marker is left alone
|
|
|
|
dist, cmd = self.get_cmd()
|
2011-08-21 17:35:41 -03:00
|
|
|
cmd.formats = ['gztar']
|
2010-08-13 23:36:26 -03:00
|
|
|
cmd.ensure_finalized()
|
|
|
|
self.write_file((self.tmp_dir, cmd.manifest), 'README.manual')
|
2011-07-30 23:06:12 -03:00
|
|
|
self.write_file((self.tmp_dir, 'README.manual'),
|
|
|
|
'This project maintains its MANIFEST file itself.')
|
2010-08-13 23:36:26 -03:00
|
|
|
cmd.run()
|
2011-07-30 23:06:12 -03:00
|
|
|
self.assertEqual(cmd.filelist.files, ['README.manual'])
|
2010-08-13 23:36:26 -03:00
|
|
|
|
|
|
|
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:48:29 -03:00
|
|
|
|
2011-07-30 23:06:12 -03:00
|
|
|
archive_name = join(self.tmp_dir, 'dist', 'fake-1.0.tar.gz')
|
|
|
|
archive = tarfile.open(archive_name)
|
|
|
|
try:
|
|
|
|
filenames = [tarinfo.name for tarinfo in archive]
|
|
|
|
finally:
|
|
|
|
archive.close()
|
|
|
|
self.assertEqual(sorted(filenames), ['fake-1.0', 'fake-1.0/PKG-INFO',
|
|
|
|
'fake-1.0/README.manual'])
|
|
|
|
|
2009-01-09 00:11:44 -04:00
|
|
|
def test_suite():
|
2009-05-16 13:52:13 -03:00
|
|
|
return unittest.makeSuite(SDistTestCase)
|
2009-01-09 00:11:44 -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
The missing NEWS entries correspond to changes that were made before 3.1.3, but
I think it’s not usual to edit entries of released versions, so I put them at
the top.
........
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 17:38:37 -04:00
|
|
|
run_unittest(test_suite())
|