summaryrefslogtreecommitdiff
path: root/tests/test_check.py
diff options
context:
space:
mode:
authorBerker Peksag <berker.peksag@gmail.com>2016-10-04 20:54:44 +0300
committerBerker Peksag <berker.peksag@gmail.com>2016-10-04 20:54:44 +0300
commit06e8590eef402ebcb2a179875572549b5fe8d946 (patch)
tree445af0378dfb8278a376fb4cf766ec13666f7273 /tests/test_check.py
parent0c6f3d33cd15a4558e437b70b0507f221f00e3eb (diff)
downloadpython-setuptools-git-06e8590eef402ebcb2a179875572549b5fe8d946.tar.gz
Issue #28222: Don't fail if pygments is not available
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().
Diffstat (limited to 'tests/test_check.py')
-rw-r--r--tests/test_check.py16
1 files changed, 14 insertions, 2 deletions
diff --git a/tests/test_check.py b/tests/test_check.py
index 959fa908..3d22868e 100644
--- a/tests/test_check.py
+++ b/tests/test_check.py
@@ -7,6 +7,12 @@ from distutils.command.check import check, HAS_DOCUTILS
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):
@@ -119,9 +125,15 @@ class CheckTestCase(support.LoggingSilencer,
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):