2008-06-05 03:58:43 -05:00
|
|
|
#!/usr/bin/env python
|
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
"""
|
|
|
|
Sphinx unit test driver
|
|
|
|
~~~~~~~~~~~~~~~~~~~~~~~
|
|
|
|
|
|
|
|
This script runs the Sphinx unit test suite.
|
|
|
|
|
2017-03-22 06:21:12 -05:00
|
|
|
:copyright: Copyright 2007-2017 by the Sphinx team, see AUTHORS.
|
2009-01-03 04:57:07 -06:00
|
|
|
:license: BSD, see LICENSE for details.
|
2008-06-05 03:58:43 -05:00
|
|
|
"""
|
2014-01-19 04:17:10 -06:00
|
|
|
from __future__ import print_function
|
2008-06-05 03:58:43 -05:00
|
|
|
|
2014-09-21 10:17:02 -05:00
|
|
|
import os
|
2008-06-05 03:58:43 -05:00
|
|
|
import sys
|
2016-12-14 22:12:13 -06:00
|
|
|
import warnings
|
2014-09-21 10:17:02 -05:00
|
|
|
import traceback
|
2017-05-07 02:46:44 -05:00
|
|
|
import shutil
|
2014-09-21 10:17:02 -05:00
|
|
|
|
|
|
|
testroot = os.path.dirname(__file__) or '.'
|
|
|
|
sys.path.insert(0, os.path.abspath(os.path.join(testroot, os.path.pardir)))
|
|
|
|
|
2017-01-06 09:46:26 -06:00
|
|
|
# filter warnings of test dependencies
|
|
|
|
warnings.filterwarnings('ignore', category=DeprecationWarning, module='site') # virtualenv
|
|
|
|
warnings.filterwarnings('ignore', category=ImportWarning, module='backports')
|
2017-04-27 07:24:12 -05:00
|
|
|
warnings.filterwarnings('ignore', category=ImportWarning, module='pkgutil')
|
2017-02-13 05:30:57 -06:00
|
|
|
warnings.filterwarnings('ignore', category=ImportWarning, module='pytest_cov')
|
2017-01-06 09:46:26 -06:00
|
|
|
warnings.filterwarnings('ignore', category=PendingDeprecationWarning, module=r'_pytest\..*')
|
|
|
|
|
2014-09-21 10:17:02 -05:00
|
|
|
# check dependencies before testing
|
|
|
|
print('Checking dependencies...')
|
2017-01-03 07:24:00 -06:00
|
|
|
for modname in ('pytest', 'mock', 'six', 'docutils', 'jinja2', 'pygments',
|
2016-05-28 01:51:21 -05:00
|
|
|
'snowballstemmer', 'babel', 'html5lib'):
|
2014-09-21 10:17:02 -05:00
|
|
|
try:
|
|
|
|
__import__(modname)
|
|
|
|
except ImportError as err:
|
2014-09-21 10:32:52 -05:00
|
|
|
if modname == 'mock' and sys.version_info[0] == 3:
|
|
|
|
continue
|
2014-09-21 10:17:02 -05:00
|
|
|
traceback.print_exc()
|
|
|
|
print('The %r package is needed to run the Sphinx test suite.' % modname)
|
|
|
|
sys.exit(1)
|
|
|
|
|
|
|
|
# find a temp dir for testing and clean it up now
|
|
|
|
os.environ['SPHINX_TEST_TEMPDIR'] = \
|
|
|
|
os.path.abspath(os.path.join(testroot, 'build')) \
|
|
|
|
if 'SPHINX_TEST_TEMPDIR' not in os.environ \
|
|
|
|
else os.path.abspath(os.environ['SPHINX_TEST_TEMPDIR'])
|
2017-05-07 02:46:44 -05:00
|
|
|
|
|
|
|
tempdir = os.environ['SPHINX_TEST_TEMPDIR']
|
2014-09-21 10:17:02 -05:00
|
|
|
print('Temporary files will be placed in %s.' % tempdir)
|
2017-05-07 02:46:44 -05:00
|
|
|
if os.path.exists(tempdir):
|
|
|
|
shutil.rmtree(tempdir)
|
|
|
|
os.makedirs(tempdir)
|
2011-04-12 17:54:14 -05:00
|
|
|
|
2014-11-06 02:12:51 -06:00
|
|
|
print('Running Sphinx test suite (with Python %s)...' % sys.version.split()[0])
|
2014-09-21 12:01:03 -05:00
|
|
|
sys.stdout.flush()
|
|
|
|
|
2017-01-25 10:13:17 -06:00
|
|
|
import pytest # NOQA
|
2017-10-26 10:59:46 -05:00
|
|
|
sys.exit(pytest.main(sys.argv[1:]))
|