Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion Lib/distutils/command/check.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ def check_restructuredtext(self):

def _check_rst_data(self, data):
"""Returns warnings when the provided data doesn't compile."""
source_path = StringIO()
source_path = self.distribution.script_name or 'setup.py'
parser = Parser()
settings = frontend.OptionParser(components=(Parser,)).get_default_values()
settings.tab_width = 4
Expand All @@ -135,6 +135,7 @@ def _check_rst_data(self, data):
error_handler=settings.error_encoding_error_handler)

document = nodes.document(settings, reporter, source=source_path)
# the include and csv_table directives need this to be a path
document.note_source(source_path, -1)
try:
parser.parse(data, document)
Expand Down
1 change: 1 addition & 0 deletions Lib/distutils/tests/includetest.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
This should be included.
10 changes: 10 additions & 0 deletions Lib/distutils/tests/test_check.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""Tests for distutils.command.check."""
import textwrap
import unittest
from pathlib import Path
from test.support import run_unittest

from distutils.command.check import check, HAS_DOCUTILS
Expand All @@ -13,6 +14,10 @@
pygments = None


HERE = Path(__file__).parent
INCLUDE_TEST_PATH = (HERE / 'includetest.rst').relative_to(Path.cwd())
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would you mind using os.path functions to make it easier to backport the patch?



class CheckTestCase(support.LoggingSilencer,
support.TempdirManager,
unittest.TestCase):
Expand Down Expand Up @@ -99,6 +104,11 @@ def test_check_restructuredtext(self):
cmd = self._run(metadata, strict=1, restructuredtext=1)
self.assertEqual(cmd._warnings, 0)

# check that includes work to test #31292
metadata['long_description'] = 'title\n=====\n\n.. include:: {}'.format(INCLUDE_TEST_PATH)
cmd = self._run(metadata, strict=1, restructuredtext=1)
self.assertEqual(cmd._warnings, 0)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it possible to test the value of the long description (to see the desired text included)?


@unittest.skipUnless(HAS_DOCUTILS, "won't test without docutils")
def test_check_restructuredtext_with_syntax_highlight(self):
# Don't fail if there is a `code` or `code-block` directive
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Fix ``setup.py check --restructuredtext`` for
files containing ``.. include::`` directives.