Skip to content

Commit b5bb404

Browse files
committed
Issue python#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().
1 parent 002b0a7 commit b5bb404

1 file changed

Lines changed: 14 additions & 2 deletions

File tree

‎Lib/distutils/tests/test_check.py‎

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,12 @@
77
from distutils.tests import support
88
from distutils.errors import DistutilsSetupError
99

10+
try:
11+
import pygments
12+
except ImportError:
13+
pygments = None
14+
15+
1016
class CheckTestCase(support.LoggingSilencer,
1117
support.TempdirManager,
1218
unittest.TestCase):
@@ -119,9 +125,15 @@ def foo():
119125
pkg_info, dist = self.create_dist(long_description=rest_with_code)
120126
cmd = check(dist)
121127
cmd.check_restructuredtext()
122-
self.assertEqual(cmd._warnings, 0)
123128
msgs = cmd._check_rst_data(rest_with_code)
124-
self.assertEqual(len(msgs), 0)
129+
if pygments is not None:
130+
self.assertEqual(len(msgs), 0)
131+
else:
132+
self.assertEqual(len(msgs), 1)
133+
self.assertEqual(
134+
str(msgs[0][1]),
135+
'Cannot analyze code. Pygments package not found.'
136+
)
125137

126138
def test_check_all(self):
127139

0 commit comments

Comments
 (0)