From 8fda21099d33696b84318c51e22a807cda9f32da Mon Sep 17 00:00:00 2001 From: Takeshi KOMIYA Date: Thu, 27 Apr 2017 23:38:42 +0900 Subject: [PATCH] Remove deprecated testing utilities --- tests/test_build_html5.py | 11 +-- tests/test_build_latex.py | 8 +- tests/test_build_texinfo.py | 4 +- tests/test_build_text.py | 5 +- tests/test_docutilsconf.py | 4 +- tests/test_ext_math.py | 9 +- tests/test_quickstart.py | 4 +- tests/util.py | 160 ------------------------------------ 8 files changed, 18 insertions(+), 187 deletions(-) diff --git a/tests/test_build_html5.py b/tests/test_build_html5.py index b491b6306..e43decaf9 100644 --- a/tests/test_build_html5.py +++ b/tests/test_build_html5.py @@ -14,19 +14,13 @@ :license: BSD, see LICENSE for details. """ -import os -import re -from itertools import cycle, chain import xml.etree.cElementTree as ElementTree -from six import PY3 import pytest from html5lib import getTreeBuilder, HTMLParser -from sphinx import __display_version__ from sphinx.util.docutils import is_html5_writer_available -from util import remove_unicode_literals, strip_escseq, skip_unless from test_build_html import flat_dict, tail_check, check_xpath TREE_BUILDER = getTreeBuilder('etree', implementation=ElementTree) @@ -35,7 +29,8 @@ HTML_PARSER = HTMLParser(TREE_BUILDER, namespaceHTMLElements=False) etree_cache = {} -@skip_unless(is_html5_writer_available()) + +@pytest.mark.skipif(not is_html5_writer_available(), reason='HTML5 writer is not available') @pytest.fixture(scope='module') def cached_etree_parse(): def parse(fname): @@ -50,7 +45,7 @@ def cached_etree_parse(): etree_cache.clear() -@skip_unless(is_html5_writer_available()) +@pytest.mark.skipif(not is_html5_writer_available(), reason='HTML5 writer is not available') @pytest.mark.parametrize("fname,expect", flat_dict({ 'images.html': [ (".//img[@src='_images/img.png']", ''), diff --git a/tests/test_build_latex.py b/tests/test_build_latex.py index ad882758c..3cda73546 100644 --- a/tests/test_build_latex.py +++ b/tests/test_build_latex.py @@ -24,7 +24,7 @@ from sphinx.util.osutil import cd, ensuredir from sphinx.util import docutils from sphinx.writers.latex import LaTeXTranslator -from util import SkipTest, remove_unicode_literals, strip_escseq, skip_if +from util import remove_unicode_literals, strip_escseq from test_build_html import ENV_WARNINGS @@ -77,7 +77,7 @@ def compile_latex_document(app): 'SphinxTests.tex'], stdout=PIPE, stderr=PIPE) except OSError: # most likely the latex executable was not found - raise SkipTest + raise pytest.skip.Exception else: stdout, stderr = p.communicate() if p.returncode != 0: @@ -90,7 +90,7 @@ def compile_latex_document(app): def skip_if_requested(testfunc): if 'SKIP_LATEX_BUILD' in os.environ: msg = 'Skip LaTeX builds because SKIP_LATEX_BUILD is set' - return skip_if(True, msg)(testfunc) + return pytest.mark.skipif(True, reason=msg)(testfunc) else: return testfunc @@ -98,7 +98,7 @@ def skip_if_requested(testfunc): def skip_if_stylefiles_notfound(testfunc): if kpsetest(*STYLEFILES) is False: msg = 'not running latex, the required styles do not seem to be installed' - return skip_if(True, msg)(testfunc) + return pytest.mark.skipif(True, reason=msg)(testfunc) else: return testfunc diff --git a/tests/test_build_texinfo.py b/tests/test_build_texinfo.py index 0177bc392..68b0e2067 100644 --- a/tests/test_build_texinfo.py +++ b/tests/test_build_texinfo.py @@ -19,7 +19,7 @@ import pytest from sphinx.writers.texinfo import TexinfoTranslator -from util import SkipTest, remove_unicode_literals, strip_escseq +from util import remove_unicode_literals, strip_escseq from test_build_html import ENV_WARNINGS @@ -58,7 +58,7 @@ def test_texinfo(app, status, warning): p = Popen(['makeinfo', '--no-split', 'SphinxTests.texi'], stdout=PIPE, stderr=PIPE) except OSError: - raise SkipTest # most likely makeinfo was not found + raise pytest.skip.Exception # most likely makeinfo was not found else: stdout, stderr = p.communicate() retcode = p.returncode diff --git a/tests/test_build_text.py b/tests/test_build_text.py index 6ce3b5276..81e354ecd 100644 --- a/tests/test_build_text.py +++ b/tests/test_build_text.py @@ -8,12 +8,11 @@ :copyright: Copyright 2007-2017 by the Sphinx team, see AUTHORS. :license: BSD, see LICENSE for details. """ +import pytest from docutils.utils import column_width from sphinx.writers.text import MAXWIDTH -from util import with_app - def with_text_app(*args, **kw): default_kw = { @@ -21,7 +20,7 @@ def with_text_app(*args, **kw): 'testroot': 'build-text', } default_kw.update(kw) - return with_app(*args, **default_kw) + return pytest.mark.sphinx(*args, **default_kw) @with_text_app() diff --git a/tests/test_docutilsconf.py b/tests/test_docutilsconf.py index 3c43b6e7c..fe848de2e 100644 --- a/tests/test_docutilsconf.py +++ b/tests/test_docutilsconf.py @@ -12,7 +12,7 @@ import re import pytest -from util import path, SkipTest +from util import path def regex_count(expr, result): @@ -78,7 +78,7 @@ def test_docutils_source_link_with_nonascii_file(app, status, warning): (srcdir / (mb_name + '.txt')).write_text('') except UnicodeEncodeError: from path import FILESYSTEMENCODING - raise SkipTest( + raise pytest.skip.Exception( 'nonascii filename not supported on this filesystem encoding: ' '%s', FILESYSTEMENCODING) diff --git a/tests/test_ext_math.py b/tests/test_ext_math.py index 296bba94f..a6de6b788 100644 --- a/tests/test_ext_math.py +++ b/tests/test_ext_math.py @@ -12,7 +12,6 @@ import re import pytest -from util import SkipTest @pytest.mark.sphinx( @@ -40,9 +39,9 @@ def test_jsmath(app, status, warning): def test_imgmath_png(app, status, warning): app.builder.build_all() if "LaTeX command 'latex' cannot be run" in warning.getvalue(): - raise SkipTest('LaTeX command "latex" is not available') + raise pytest.skip.Exception('LaTeX command "latex" is not available') if "dvipng command 'dvipng' cannot be run" in warning.getvalue(): - raise SkipTest('dvipng command "dvipng" is not available') + raise pytest.skip.Exception('dvipng command "dvipng" is not available') content = (app.outdir / 'index.html').text() html = (r'
\s*

\s*\s*

\s*