Skip to content

Commit 808d00d

Browse files
committed
Check if sphinx-build available before executing the test
1 parent d308eec commit 808d00d

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

lib/matplotlib/sphinxext/tests/test_tinypages.py

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@
1414
TINY_PAGES = pjoin(HERE, 'tinypages')
1515

1616

17-
def setup():
18-
# Check we have the sphinx-build command
17+
def check_sphinx_build():
18+
"""Check we have the sphinx-build command"""
1919
try:
2020
ret = call(['sphinx-build', '--help'], stdout=PIPE, stderr=PIPE)
2121
except OSError:
@@ -33,10 +33,11 @@ def file_same(file1, file2):
3333

3434

3535
class TestTinyPages(object):
36-
# Test build and output of tinypages project
36+
"""Test build and output of tinypages project"""
3737

3838
@classmethod
3939
def setup_class(cls):
40+
check_sphinx_build()
4041
cls.page_build = tempfile.mkdtemp()
4142
try:
4243
cls.html_dir = pjoin(cls.page_build, 'html')
@@ -48,14 +49,12 @@ def setup_class(cls):
4849
cls.html_dir]
4950
proc = Popen(cmd, stdout=PIPE, stderr=PIPE)
5051
out, err = proc.communicate()
52+
if proc.returncode != 0:
53+
raise RuntimeError('sphinx-build failed with stdout:\n'
54+
'{0}\nstderr:\n{1}\n'.format(out, err))
5155
except Exception as e:
5256
shutil.rmtree(cls.page_build)
5357
raise e
54-
if proc.returncode != 0:
55-
shutil.rmtree(cls.page_build)
56-
raise RuntimeError('sphinx-build failed with stdout:\n'
57-
'{0}\nstderr:\n{1}\n'.format(
58-
out, err))
5958

6059
@classmethod
6160
def teardown_class(cls):

0 commit comments

Comments
 (0)