summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sphinx/ext/autodoc.py5
-rwxr-xr-xtests/path.py3
-rwxr-xr-xtests/run.py5
-rw-r--r--tests/test_directive_code.py16
-rw-r--r--tests/test_ext_graphviz.py2
-rw-r--r--tests/test_intl.py15
-rw-r--r--tests/util.py8
7 files changed, 34 insertions, 20 deletions
diff --git a/sphinx/ext/autodoc.py b/sphinx/ext/autodoc.py
index c17b754e7..c3832bfda 100644
--- a/sphinx/ext/autodoc.py
+++ b/sphinx/ext/autodoc.py
@@ -15,6 +15,7 @@ import re
import sys
import inspect
import traceback
+import warnings
from types import FunctionType, BuiltinFunctionType, MethodType
from six import PY2, iterkeys, iteritems, itervalues, text_type, class_types, \
@@ -544,7 +545,9 @@ class Documenter(object):
for modname in self.env.config.autodoc_mock_imports:
dbg('[autodoc] adding a mock module %s!', modname)
mock_import(modname)
- __import__(self.modname)
+ with warnings.catch_warnings():
+ warnings.filterwarnings("ignore", category=ImportWarning)
+ __import__(self.modname)
parent = None
obj = self.module = sys.modules[self.modname]
dbg('[autodoc] => %r', obj)
diff --git a/tests/path.py b/tests/path.py
index 959b54875..ef1f35004 100755
--- a/tests/path.py
+++ b/tests/path.py
@@ -142,7 +142,8 @@ class path(text_type):
"""
Returns the text in the file.
"""
- with open(self, mode='U', encoding=encoding, **kwargs) as f:
+ mode = 'rU' if PY2 else 'r'
+ with open(self, mode=mode, encoding=encoding, **kwargs) as f:
text = f.read()
contents = repr_as(text, '<%s contents>' % self.basename())
return contents
diff --git a/tests/run.py b/tests/run.py
index d2d3b9fc8..273b2ee6b 100755
--- a/tests/run.py
+++ b/tests/run.py
@@ -13,6 +13,7 @@ from __future__ import print_function
import os
import sys
+import warnings
import traceback
from path import path
@@ -48,4 +49,8 @@ tempdir.makedirs()
print('Running Sphinx test suite (with Python %s)...' % sys.version.split()[0])
sys.stdout.flush()
+# filter warnings of test dependencies
+warnings.filterwarnings('ignore', category=DeprecationWarning, module='nose.util')
+warnings.filterwarnings('ignore', category=DeprecationWarning, module='site') # virtualenv
+
nose.main(argv=sys.argv)
diff --git a/tests/test_directive_code.py b/tests/test_directive_code.py
index 8f926956e..cb6221355 100644
--- a/tests/test_directive_code.py
+++ b/tests/test_directive_code.py
@@ -9,15 +9,13 @@
:license: BSD, see LICENSE for details.
"""
-from xml.etree import ElementTree
-
-from util import with_app
+from util import with_app, etree_parse
@with_app('xml', testroot='directive-code')
def test_code_block(app, status, warning):
app.builder.build('index')
- et = ElementTree.parse(app.outdir / 'index.xml')
+ et = etree_parse(app.outdir / 'index.xml')
secs = et.findall('./section/section')
code_block = secs[0].findall('literal_block')
assert len(code_block) > 0
@@ -33,7 +31,7 @@ def test_code_block(app, status, warning):
@with_app('xml', testroot='directive-code')
def test_code_block_dedent(app, status, warning):
app.builder.build(['dedent_code'])
- et = ElementTree.parse(app.outdir / 'dedent_code.xml')
+ et = etree_parse(app.outdir / 'dedent_code.xml')
blocks = et.findall('./section/section/literal_block')
for i in range(5): # 0-4
@@ -94,7 +92,7 @@ def test_code_block_namedlink_latex(app, status, warning):
@with_app('xml', testroot='directive-code')
def test_literal_include(app, status, warning):
app.builder.build(['index'])
- et = ElementTree.parse(app.outdir / 'index.xml')
+ et = etree_parse(app.outdir / 'index.xml')
secs = et.findall('./section/section')
literal_include = secs[1].findall('literal_block')
literal_src = (app.srcdir / 'literal.inc').text(encoding='utf-8')
@@ -109,7 +107,7 @@ def test_literal_include_dedent(app, status, warning):
literal_lines = [l[4:] for l in literal_src.split('\n')[9:11]]
app.builder.build(['dedent'])
- et = ElementTree.parse(app.outdir / 'dedent.xml')
+ et = etree_parse(app.outdir / 'dedent.xml')
blocks = et.findall('./section/section/literal_block')
for i in range(5): # 0-4
@@ -124,7 +122,7 @@ def test_literal_include_dedent(app, status, warning):
@with_app('xml', testroot='directive-code')
def test_literal_include_block_start_with_comment_or_brank(app, status, warning):
app.builder.build(['python'])
- et = ElementTree.parse(app.outdir / 'python.xml')
+ et = etree_parse(app.outdir / 'python.xml')
secs = et.findall('./section/section')
literal_include = secs[0].findall('literal_block')
assert len(literal_include) > 0
@@ -290,7 +288,7 @@ def test_literalinclude_namedlink_latex(app, status, warning):
@with_app('xml', testroot='directive-code')
def test_literalinclude_classes(app, status, warning):
app.builder.build(['classes'])
- et = ElementTree.parse(app.outdir / 'classes.xml')
+ et = etree_parse(app.outdir / 'classes.xml')
secs = et.findall('./section/section')
code_block = secs[0].findall('literal_block')
diff --git a/tests/test_ext_graphviz.py b/tests/test_ext_graphviz.py
index aa97f4135..7d464343f 100644
--- a/tests/test_ext_graphviz.py
+++ b/tests/test_ext_graphviz.py
@@ -26,7 +26,7 @@ def skip_if_graphviz_not_found(fn):
dot = subprocess.Popen([graphviz_dot, '-V'],
stdout=subprocess.PIPE,
stderr=subprocess.PIPE) # show version
- dot.wait()
+ dot.communicate()
found = True
except OSError: # No such file or directory
pass
diff --git a/tests/test_intl.py b/tests/test_intl.py
index 4a517c111..21d6f763b 100644
--- a/tests/test_intl.py
+++ b/tests/test_intl.py
@@ -16,7 +16,6 @@ import re
import pickle
from docutils import nodes
from subprocess import Popen, PIPE
-from xml.etree import ElementTree
from babel.messages import pofile
from nose.tools import assert_equal
@@ -24,7 +23,7 @@ from six import string_types
from util import tempdir, rootdir, path, gen_with_app, with_app, SkipTest, \
assert_re_search, assert_not_re_search, assert_in, assert_not_in, \
- assert_startswith, assert_node, repr_as
+ assert_startswith, assert_node, repr_as, etree_parse
root = tempdir / 'test-intl'
@@ -502,7 +501,7 @@ def test_xml_builder(app, status, warning):
# --- footnotes: regression test for fix #955, #1176
- et = ElementTree.parse(app.outdir / 'footnote.xml')
+ et = etree_parse(app.outdir / 'footnote.xml')
secs = et.findall('section')
para0 = secs[0].findall('paragraph')
@@ -542,7 +541,7 @@ def test_xml_builder(app, status, warning):
# --- footnote backlinks: i18n test for #1058
- et = ElementTree.parse(app.outdir / 'footnote.xml')
+ et = etree_parse(app.outdir / 'footnote.xml')
secs = et.findall('section')
para0 = secs[0].findall('paragraph')
@@ -558,7 +557,7 @@ def test_xml_builder(app, status, warning):
# --- refs in the Python domain
- et = ElementTree.parse(app.outdir / 'refs_python_domain.xml')
+ et = etree_parse(app.outdir / 'refs_python_domain.xml')
secs = et.findall('section')
# regression test for fix #1363
@@ -570,7 +569,7 @@ def test_xml_builder(app, status, warning):
# --- keep external links: regression test for #1044
- et = ElementTree.parse(app.outdir / 'external_links.xml')
+ et = etree_parse(app.outdir / 'external_links.xml')
secs = et.findall('section')
para0 = secs[0].findall('paragraph')
@@ -623,7 +622,7 @@ def test_xml_builder(app, status, warning):
# --- role xref: regression test for #1090, #1193
- et = ElementTree.parse(app.outdir / 'role_xref.xml')
+ et = etree_parse(app.outdir / 'role_xref.xml')
sec1, sec2 = et.findall('section')
para1, = sec1.findall('paragraph')
@@ -674,7 +673,7 @@ def test_xml_builder(app, status, warning):
# --- label targets: regression test for #1193, #1265
- et = ElementTree.parse(app.outdir / 'label_target.xml')
+ et = etree_parse(app.outdir / 'label_target.xml')
secs = et.findall('section')
para0 = secs[0].findall('paragraph')
diff --git a/tests/util.py b/tests/util.py
index 120492d47..13366a1da 100644
--- a/tests/util.py
+++ b/tests/util.py
@@ -11,7 +11,9 @@ import os
import re
import sys
import tempfile
+import warnings
from functools import wraps
+from xml.etree import ElementTree
from six import StringIO, string_types
@@ -155,6 +157,12 @@ def skip_unless_importable(module, msg=None):
return skip_if(False, msg)
+def etree_parse(path):
+ with warnings.catch_warnings(record=False):
+ warnings.filterwarnings("ignore", category=DeprecationWarning)
+ return ElementTree.parse(path)
+
+
class Struct(object):
def __init__(self, **kwds):
self.__dict__.update(kwds)