summaryrefslogtreecommitdiff
path: root/sphinx/testing/util.py
diff options
context:
space:
mode:
Diffstat (limited to 'sphinx/testing/util.py')
-rw-r--r--sphinx/testing/util.py162
1 files changed, 0 insertions, 162 deletions
diff --git a/sphinx/testing/util.py b/sphinx/testing/util.py
index d8d06d3d4..fb2e8f1f5 100644
--- a/sphinx/testing/util.py
+++ b/sphinx/testing/util.py
@@ -12,13 +12,9 @@ import os
import re
import sys
import warnings
-from functools import wraps
from xml.etree import ElementTree
from six import string_types
-from six import StringIO
-
-import pytest
from docutils import nodes
from docutils.parsers.rst import directives, roles
@@ -27,7 +23,6 @@ from sphinx import application
from sphinx.builders.latex import LaTeXBuilder
from sphinx.ext.autodoc import AutoDirective
from sphinx.pycode import ModuleAnalyzer
-from sphinx.deprecation import RemovedInSphinx17Warning
from sphinx.testing.path import path
@@ -196,160 +191,3 @@ def find_files(root, suffix=None):
def strip_escseq(text):
return re.sub('\x1b.*?m', '', text)
-
-
-# #############################################
-# DEPRECATED implementations
-
-
-def gen_with_app(*args, **kwargs):
- """
- **DEPRECATED**: use pytest.mark.parametrize instead.
-
- Decorate a test generator to pass a SphinxTestApp as the first argument to
- the test generator when it's executed.
- """
- def generator(func):
- @wraps(func)
- def deco(*args2, **kwargs2):
- status, warning = StringIO(), StringIO()
- kwargs['status'] = status
- kwargs['warning'] = warning
- app = SphinxTestApp(*args, **kwargs)
- try:
- for item in func(app, status, warning, *args2, **kwargs2):
- yield item
- finally:
- app.cleanup()
- return deco
- return generator
-
-
-def skip_if(condition, msg=None):
- """
- **DEPRECATED**: use pytest.mark.skipif instead.
-
- Decorator to skip test if condition is true.
- """
- return pytest.mark.skipif(condition, reason=(msg or 'conditional skip'))
-
-
-def skip_unless(condition, msg=None):
- """
- **DEPRECATED**: use pytest.mark.skipif instead.
-
- Decorator to skip test if condition is false.
- """
- return pytest.mark.skipif(not condition, reason=(msg or 'conditional skip'))
-
-
-def with_tempdir(func):
- """
- **DEPRECATED**: use tempdir fixture instead.
- """
- return func
-
-
-def raises(exc, func, *args, **kwds):
- """
- **DEPRECATED**: use pytest.raises instead.
-
- Raise AssertionError if ``func(*args, **kwds)`` does not raise *exc*.
- """
- with pytest.raises(exc):
- func(*args, **kwds)
-
-
-def raises_msg(exc, msg, func, *args, **kwds):
- """
- **DEPRECATED**: use pytest.raises instead.
-
- Raise AssertionError if ``func(*args, **kwds)`` does not raise *exc*,
- and check if the message contains *msg*.
- """
- with pytest.raises(exc) as excinfo:
- func(*args, **kwds)
- assert msg in str(excinfo.value)
-
-
-def assert_true(v1, msg=''):
- """
- **DEPRECATED**: use assert instead.
- """
- assert v1, msg
-
-
-def assert_equal(v1, v2, msg=''):
- """
- **DEPRECATED**: use assert instead.
- """
- assert v1 == v2, msg
-
-
-def assert_in(x, thing, msg=''):
- """
- **DEPRECATED**: use assert instead.
- """
- if x not in thing:
- assert False, msg or '%r is not in %r' % (x, thing)
-
-
-def assert_not_in(x, thing, msg=''):
- """
- **DEPRECATED**: use assert instead.
- """
- if x in thing:
- assert False, msg or '%r is in %r' % (x, thing)
-
-
-class ListOutput(object):
- """
- File-like object that collects written text in a list.
- """
- def __init__(self, name):
- self.name = name
- self.content = [] # type: List[str]
-
- def reset(self):
- del self.content[:]
-
- def write(self, text):
- self.content.append(text)
-
-
-# **DEPRECATED**: use pytest.skip instead.
-SkipTest = pytest.skip.Exception
-
-
-class _DeprecationWrapper(object):
- def __init__(self, mod, deprecated):
- self._mod = mod
- self._deprecated = deprecated
-
- def __getattr__(self, attr):
- if attr in self._deprecated:
- obj, instead = self._deprecated[attr]
- warnings.warn("tests/util.py::%s is deprecated and will be "
- "removed in Sphinx 1.7, please use %s instead."
- % (attr, instead),
- RemovedInSphinx17Warning, stacklevel=2)
- return obj
- return getattr(self._mod, attr)
-
-
-sys.modules[__name__] = _DeprecationWrapper(sys.modules[__name__], dict(
- with_app=(pytest.mark.sphinx, 'pytest.mark.sphinx'),
- TestApp=(SphinxTestApp, 'SphinxTestApp'),
- gen_with_app=(gen_with_app, 'pytest.mark.parametrize'),
- skip_if=(skip_if, 'pytest.skipif'),
- skip_unless=(skip_unless, 'pytest.skipif'),
- with_tempdir=(with_tempdir, 'tmpdir pytest fixture'),
- raises=(raises, 'pytest.raises'),
- raises_msg=(raises_msg, 'pytest.raises'),
- assert_true=(assert_true, 'assert'),
- assert_equal=(assert_equal, 'assert'),
- assert_in=(assert_in, 'assert'),
- assert_not_in=(assert_not_in, 'assert'),
- ListOutput=(ListOutput, 'StringIO'),
- SkipTest=(SkipTest, 'pytest.skip'),
-))