11"""Tests for distutils.command.register."""
2- import sys
32import os
43import unittest
54import getpass
109
1110from distutils .command import register as register_module
1211from distutils .command .register import register
13- from distutils .core import Distribution
1412from distutils .errors import DistutilsSetupError
1513
16- from distutils .tests import support
17- from distutils .tests .test_config import PYPIRC , PyPIRCCommandTestCase
14+ from distutils .tests .test_config import PyPIRCCommandTestCase
15+
16+ try :
17+ import docutils
18+ except ImportError :
19+ docutils = None
1820
1921PYPIRC_NOPASSWORD = """\
2022 [distutils]
@@ -193,6 +195,7 @@ def test_password_reset(self):
193195 self .assertEqual (headers ['Content-length' ], '290' )
194196 self .assertTrue ((b'tarek' ) in req .data )
195197
198+ @unittest .skipUnless (docutils is not None , 'needs docutils' )
196199 def test_strict (self ):
197200 # testing the script option
198201 # when on, the register command stops if
@@ -205,13 +208,6 @@ def test_strict(self):
205208 cmd .strict = 1
206209 self .assertRaises (DistutilsSetupError , cmd .run )
207210
208- # we don't test the reSt feature if docutils
209- # is not installed
210- try :
211- import docutils
212- except ImportError :
213- return
214-
215211 # metadata are OK but long_description is broken
216212 metadata = {'url' : 'xxx' , 'author' : 'xxx' ,
217213 'author_email' : 'éxéxé' ,
@@ -265,6 +261,22 @@ def test_strict(self):
265261 finally :
266262 del register_module .input
267263
264+ @unittest .skipUnless (docutils is not None , 'needs docutils' )
265+ def test_register_invalid_long_description (self ):
266+ description = ':funkie:`str`' # mimic Sphinx-specific markup
267+ metadata = {'url' : 'xxx' , 'author' : 'xxx' ,
268+ 'author_email' : 'xxx' ,
269+ 'name' : 'xxx' , 'version' : 'xxx' ,
270+ 'long_description' : description }
271+ cmd = self ._get_cmd (metadata )
272+ cmd .ensure_finalized ()
273+ cmd .strict = True
274+ inputs = Inputs (
'2' ,
'tarek' ,
'[email protected] ' )
275+ register_module .input = inputs
276+ self .addCleanup (delattr , register_module , 'input' )
277+
278+ self .assertRaises (DistutilsSetupError , cmd .run )
279+
268280 def test_check_metadata_deprecated (self ):
269281 # makes sure make_metadata is deprecated
270282 cmd = self ._get_cmd ()
0 commit comments