diff options
| author | Philipp A <flying-sheep@web.de> | 2019-03-27 22:34:19 +0100 |
|---|---|---|
| committer | Cheryl Sabella <cheryl.sabella@gmail.com> | 2019-03-27 17:34:19 -0400 |
| commit | 868d8498bbccf63c274056959055800d02cac0d5 (patch) | |
| tree | 91853e58785edcf2b36c3f8309f5a83e96889dd3 | |
| parent | 4c6000461394d2a969c17b98ff7b64e7d6f6eee4 (diff) | |
| download | python-setuptools-git-868d8498bbccf63c274056959055800d02cac0d5.tar.gz | |
bpo-31292: Fixed distutils check --restructuredtext for include directives (GH-10605)
| -rw-r--r-- | command/check.py | 3 | ||||
| -rw-r--r-- | tests/includetest.rst | 1 | ||||
| -rw-r--r-- | tests/test_check.py | 16 |
3 files changed, 18 insertions, 2 deletions
diff --git a/command/check.py b/command/check.py index 7ebe707c..04c2f964 100644 --- a/command/check.py +++ b/command/check.py @@ -120,7 +120,8 @@ class check(Command): 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 diff --git a/tests/includetest.rst b/tests/includetest.rst new file mode 100644 index 00000000..d7b4ae38 --- /dev/null +++ b/tests/includetest.rst @@ -0,0 +1 @@ +This should be included. diff --git a/tests/test_check.py b/tests/test_check.py index 3d22868e..e534aca1 100644 --- a/tests/test_check.py +++ b/tests/test_check.py @@ -1,4 +1,5 @@ """Tests for distutils.command.check.""" +import os import textwrap import unittest from test.support import run_unittest @@ -13,13 +14,19 @@ except ImportError: 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() @@ -27,6 +34,8 @@ class CheckTestCase(support.LoggingSilencer, 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): @@ -99,6 +108,11 @@ class CheckTestCase(support.LoggingSilencer, 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 |
