提交 52c8f93b 编写于 作者: C Cleber Rosa

Doc test: check condition for building the docs with Sphinx

Sphinx will attempt to fetch the Python objects inventory during the build
process. If for some reason, this test is being run on a machine that can
not access that address simply because of network restrictions (or the
developer may simply be on a plane) then it's better to SKIP the test than
to give a false positive.

Changes from v0:
 * Use unittest2 on Python 2.6
Signed-off-by: NCleber Rosa <crosa@redhat.com>
上级 68bd50de
......@@ -5,7 +5,12 @@ This is geared towards documentation build regression testing.
"""
import os
import sys
import unittest
import urllib
if sys.version_info[:2] == (2, 6):
import unittest2 as unittest
else:
import unittest
from avocado.utils import process
......@@ -18,8 +23,26 @@ class DocBuildError(Exception):
pass
def has_no_external_connectivity():
"""
Check condition for building the docs with Sphinx
Sphinx will attempt to fetch the Python objects inventory during the build
process. If for some reason, this test is being run on a machine that can
not access that address simply because of network restrictions (or the
developer may simply be on a plane) then it's better to SKIP the test than
to give a false positive.
"""
try:
urllib.urlopen('http://docs.python.org/objects.inv')
return False
except:
return True
class DocBuildTest(unittest.TestCase):
@unittest.skipIf(has_no_external_connectivity(), "No external connectivity")
def test_build_docs(self):
"""
Build avocado HTML docs, reporting failures
......@@ -52,3 +75,7 @@ class DocBuildTest(unittest.TestCase):
e_msg += ('Full output: %s\n' % '\n'.join(output_lines))
e_msg += 'Please check the output and fix your docstrings/.rst docs'
raise DocBuildError(e_msg)
if __name__ == '__main__':
unittest.main()
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册