[Python-checkins] bpo-28222: Don't fail if pygments is not available (GH-7564)

Zachary Ware webhook-mailer at python.org
Sat Jun 9 14:50:26 EDT 2018


https://github.com/python/cpython/commit/f6645ef027762adbb159a3b6d64a15538672eaa2
commit: f6645ef027762adbb159a3b6d64a15538672eaa2
branch: 2.7
author: Zachary Ware <zachary.ware at gmail.com>
committer: GitHub <noreply at github.com>
date: 2018-06-09T13:50:23-05:00
summary:

bpo-28222: Don't fail if pygments is not available (GH-7564)

We can't just skip the test if docutils is available,
but pygments is not because the purpose of the test
was testing a bug in _check_rst_data().

(cherry-picked from b5bb404ccaa9a3dd81e220fb4ca40253be778831)

files:
M Lib/distutils/tests/test_check.py

diff --git a/Lib/distutils/tests/test_check.py b/Lib/distutils/tests/test_check.py
index 81058b1911ee..e94647ffa4a7 100644
--- a/Lib/distutils/tests/test_check.py
+++ b/Lib/distutils/tests/test_check.py
@@ -8,6 +8,12 @@
 from distutils.tests import support
 from distutils.errors import DistutilsSetupError
 
+try:
+    import pygments
+except ImportError:
+    pygments = None
+
+
 class CheckTestCase(support.LoggingSilencer,
                     support.TempdirManager,
                     unittest.TestCase):
@@ -120,9 +126,15 @@ def foo():
             pkg_info, dist = self.create_dist(long_description=rest_with_code)
             cmd = check(dist)
             cmd.check_restructuredtext()
-            self.assertEqual(cmd._warnings, 0)
             msgs = cmd._check_rst_data(rest_with_code)
-            self.assertEqual(len(msgs), 0)
+            if pygments is not None:
+                self.assertEqual(len(msgs), 0)
+            else:
+                self.assertEqual(len(msgs), 1)
+                self.assertEqual(
+                    str(msgs[0][1]),
+                    'Cannot analyze code. Pygments package not found.'
+                )
 
     def test_check_all(self):
 



More information about the Python-checkins mailing list