File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -122,7 +122,7 @@ def _check_rst_data(self, data):
122122 """Returns warnings when the provided data doesn't compile."""
123123 source_path = StringIO ()
124124 parser = Parser ()
125- settings = frontend .OptionParser ().get_default_values ()
125+ settings = frontend .OptionParser (components = ( Parser ,) ).get_default_values ()
126126 settings .tab_width = 4
127127 settings .pep_references = None
128128 settings .rfc_references = None
@@ -138,8 +138,8 @@ def _check_rst_data(self, data):
138138 document .note_source (source_path , - 1 )
139139 try :
140140 parser .parse (data , document )
141- except AttributeError :
142- reporter .messages .append (( - 1 , 'Could not finish the parsing.' ,
143- '' , {}))
141+ except AttributeError as e :
142+ reporter .messages .append (
143+ ( - 1 , 'Could not finish the parsing: %s.' % e , '' , {}))
144144
145145 return reporter .messages
Original file line number Diff line number Diff line change 11"""Tests for distutils.command.check."""
2+ import textwrap
23import unittest
34from test .support import run_unittest
45
@@ -92,6 +93,36 @@ def test_check_restructuredtext(self):
9293 cmd = self ._run (metadata , strict = 1 , restructuredtext = 1 )
9394 self .assertEqual (cmd ._warnings , 0 )
9495
96+ @unittest .skipUnless (HAS_DOCUTILS , "won't test without docutils" )
97+ def test_check_restructuredtext_with_syntax_highlight (self ):
98+ # Don't fail if there is a `code` or `code-block` directive
99+
100+ example_rst_docs = []
101+ example_rst_docs .append (textwrap .dedent ("""\
102+ Here's some code:
103+
104+ .. code:: python
105+
106+ def foo():
107+ pass
108+ """ ))
109+ example_rst_docs .append (textwrap .dedent ("""\
110+ Here's some code:
111+
112+ .. code-block:: python
113+
114+ def foo():
115+ pass
116+ """ ))
117+
118+ for rest_with_code in example_rst_docs :
119+ pkg_info , dist = self .create_dist (long_description = rest_with_code )
120+ cmd = check (dist )
121+ cmd .check_restructuredtext ()
122+ self .assertEqual (cmd ._warnings , 0 )
123+ msgs = cmd ._check_rst_data (rest_with_code )
124+ self .assertEqual (len (msgs ), 0 )
125+
95126 def test_check_all (self ):
96127
97128 metadata = {'url' : 'xxx' , 'author' : 'xxx' }
Original file line number Diff line number Diff line change @@ -44,6 +44,9 @@ Core and Builtins
4444Library
4545-------
4646
47+ - Issue #23063: In the disutils' check command, fix parsing of reST with code or
48+ code-block directives.
49+
4750- Issue #23209, #23225: selectors.BaseSelector.close() now clears its internal
4851 reference to the selector mapping to break a reference cycle. Initial patch
4952 written by Martin Richard.
You can’t perform that action at this time.
0 commit comments