summaryrefslogtreecommitdiffstats
path: root/Lib/distutils/tests
diff options
context:
space:
mode:
authorÉric Araujo <merwok@netwok.org>2011-09-02 22:42:04 (GMT)
committerÉric Araujo <merwok@netwok.org>2011-09-02 22:42:04 (GMT)
commitcfbd630a27c7ef31f6883dd21dbc4ece4d7b8bc4 (patch)
treed78b3484d054e5b277c98cdda60c83517d9ea3a7 /Lib/distutils/tests
parent32e2915da5ab7c59e8cd0da68df9c8775ab4353c (diff)
downloadcpython-cfbd630a27c7ef31f6883dd21dbc4ece4d7b8bc4.zip
cpython-cfbd630a27c7ef31f6883dd21dbc4ece4d7b8bc4.tar.gz
cpython-cfbd630a27c7ef31f6883dd21dbc4ece4d7b8bc4.tar.bz2
Warn instead of crashing because of invalid path in MANIFEST.in (#8286).
sdist used to crash with a full traceback dump instead of printing a nice warning with the faulty line number.
Diffstat (limited to 'Lib/distutils/tests')
-rw-r--r--Lib/distutils/tests/test_sdist.py28
1 files changed, 27 insertions, 1 deletions
diff --git a/Lib/distutils/tests/test_sdist.py b/Lib/distutils/tests/test_sdist.py
index f9e28c8..529b4ef 100644
--- a/Lib/distutils/tests/test_sdist.py
+++ b/Lib/distutils/tests/test_sdist.py
@@ -15,6 +15,7 @@ from distutils.tests.test_config import PyPIRCCommandTestCase
from distutils.errors import DistutilsOptionError
from distutils.spawn import find_executable
from distutils.log import WARN
+from distutils.filelist import FileList
from distutils.archive_util import ARCHIVE_FORMATS
SETUP_PY = """
@@ -265,7 +266,6 @@ class SDistTestCase(PyPIRCCommandTestCase):
self.assertEqual(len(output), num_formats)
def test_finalize_options(self):
-
dist, cmd = self.get_cmd()
cmd.finalize_options()
@@ -285,6 +285,32 @@ class SDistTestCase(PyPIRCCommandTestCase):
cmd.formats = 'supazipa'
self.assertRaises(DistutilsOptionError, cmd.finalize_options)
+ # the following tests make sure there is a nice error message instead
+ # of a traceback when parsing an invalid manifest template
+
+ def _test_template(self, content):
+ 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):
+ self._test_template('taunt knights *')
+
+ def test_invalid_template_wrong_arguments(self):
+ # this manifest command takes one argument
+ self._test_template('prune')
+
+ @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
+ self._test_template('include examples/')
+
@unittest.skipUnless(ZLIB_SUPPORT, 'Need zlib support to run')
def test_get_file_list(self):
# make sure MANIFEST is recalculated