summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorÉric Araujo <aeric@mtlpy.org>2012-12-09 03:41:11 (GMT)
committerÉric Araujo <aeric@mtlpy.org>2012-12-09 03:41:11 (GMT)
commit8b503c0a4e82ba5aadd60215bf493529ce6e1821 (patch)
tree16d939807ebff8158ee8c25c4ebd5ed0dc2cdcd7 /Lib
parent9bc9ab5f853b0ac39b399dc22517a7aa96ffc8d7 (diff)
downloadcpython-8b503c0a4e82ba5aadd60215bf493529ce6e1821.zip
cpython-8b503c0a4e82ba5aadd60215bf493529ce6e1821.tar.gz
cpython-8b503c0a4e82ba5aadd60215bf493529ce6e1821.tar.bz2
Fix setup.py register failure with invalid rst in description (#13614).
Original patch by Julien Courteau and Pierre Paul Lefebvre.
Diffstat (limited to 'Lib')
-rw-r--r--Lib/distutils/command/check.py3
-rw-r--r--Lib/distutils/tests/test_register.py34
2 files changed, 26 insertions, 11 deletions
diff --git a/Lib/distutils/command/check.py b/Lib/distutils/command/check.py
index b67c795..22b9349 100644
--- a/Lib/distutils/command/check.py
+++ b/Lib/distutils/command/check.py
@@ -23,6 +23,9 @@ try:
def system_message(self, level, message, *children, **kwargs):
self.messages.append((level, message, children, kwargs))
+ return nodes.system_message(message, level=level,
+ type=self.levels[level],
+ *children, **kwargs)
HAS_DOCUTILS = True
except Exception:
diff --git a/Lib/distutils/tests/test_register.py b/Lib/distutils/tests/test_register.py
index 5863ae1..a86b860 100644
--- a/Lib/distutils/tests/test_register.py
+++ b/Lib/distutils/tests/test_register.py
@@ -1,5 +1,4 @@
"""Tests for distutils.command.register."""
-import sys
import os
import unittest
import getpass
@@ -10,11 +9,14 @@ from test.support import check_warnings, run_unittest
from distutils.command import register as register_module
from distutils.command.register import register
-from distutils.core import Distribution
from distutils.errors import DistutilsSetupError
-from distutils.tests import support
-from distutils.tests.test_config import PYPIRC, PyPIRCCommandTestCase
+from distutils.tests.test_config import PyPIRCCommandTestCase
+
+try:
+ import docutils
+except ImportError:
+ docutils = None
PYPIRC_NOPASSWORD = """\
[distutils]
@@ -193,6 +195,7 @@ class RegisterTestCase(PyPIRCCommandTestCase):
self.assertEqual(headers['Content-length'], '290')
self.assertTrue((b'tarek') in req.data)
+ @unittest.skipUnless(docutils is not None, 'needs docutils')
def test_strict(self):
# testing the script option
# when on, the register command stops if
@@ -205,13 +208,6 @@ class RegisterTestCase(PyPIRCCommandTestCase):
cmd.strict = 1
self.assertRaises(DistutilsSetupError, cmd.run)
- # we don't test the reSt feature if docutils
- # is not installed
- try:
- import docutils
- except ImportError:
- return
-
# metadata are OK but long_description is broken
metadata = {'url': 'xxx', 'author': 'xxx',
'author_email': 'éxéxé',
@@ -265,6 +261,22 @@ class RegisterTestCase(PyPIRCCommandTestCase):
finally:
del register_module.input
+ @unittest.skipUnless(docutils is not None, 'needs docutils')
+ def test_register_invalid_long_description(self):
+ description = ':funkie:`str`' # mimic Sphinx-specific markup
+ metadata = {'url': 'xxx', 'author': 'xxx',
+ 'author_email': 'xxx',
+ 'name': 'xxx', 'version': 'xxx',
+ 'long_description': description}
+ cmd = self._get_cmd(metadata)
+ cmd.ensure_finalized()
+ cmd.strict = True
+ inputs = Inputs('2', 'tarek', 'tarek@ziade.org')
+ register_module.input = inputs
+ self.addCleanup(delattr, register_module, 'input')
+
+ self.assertRaises(DistutilsSetupError, cmd.run)
+
def test_check_metadata_deprecated(self):
# makes sure make_metadata is deprecated
cmd = self._get_cmd()