Skip to content
Merged
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,8 @@ def check_restructuredtext(self):

def _check_rst_data(self, data):
"""Returns warnings when the provided data doesn't compile."""
source_path = StringIO()
# the include and csv_table directives need this to be a path
source_path = self.distribution.script_name or 'setup.py'
parser = Parser()
settings = frontend.OptionParser(components=(Parser,)).get_default_values()
settings.tab_width = 4
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.
16 changes: 15 additions & 1 deletion Lib/distutils/tests/test_check.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Tests for distutils.command.check."""
import os
import textwrap
import unittest
from test.support import run_unittest
Expand All @@ -13,20 +14,28 @@
pygments = None


HERE = os.path.dirname(__file__)


class CheckTestCase(support.LoggingSilencer,
support.TempdirManager,
unittest.TestCase):

def _run(self, metadata=None, **options):
def _run(self, metadata=None, cwd=None, **options):
if metadata is None:
metadata = {}
if cwd is not None:
old_dir = os.getcwd()
os.chdir(cwd)
pkg_info, dist = self.create_dist(**metadata)
cmd = check(dist)
cmd.initialize_options()
for name, value in options.items():
setattr(cmd, name, value)
cmd.ensure_finalized()
cmd.run()
if cwd is not None:
os.chdir(old_dir)
return cmd

def test_check_metadata(self):
Expand Down Expand Up @@ -99,6 +108,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:: includetest.rst'
cmd = self._run(metadata, cwd=HERE, strict=1, restructuredtext=1)
self.assertEqual(cmd._warnings, 0)

@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.